fan: Do not flush look-ahead queue on fan speed change

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-01-02 19:46:06 -05:00
parent 8158dbcc21
commit e576571340
1 changed files with 6 additions and 4 deletions

View File

@ -52,16 +52,18 @@ class PrinterFan:
self.last_fan_value = value
def get_status(self, eventtime):
return {'speed': self.last_fan_value}
def _delayed_set_speed(self, value):
toolhead = self.printer.lookup_object('toolhead')
toolhead.register_lookahead_callback((lambda pt:
self.set_speed(pt, value)))
def cmd_M106(self, params):
# Set fan speed
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
gcode = self.printer.lookup_object('gcode')
value = gcode.get_float('S', params, 255., minval=0.) / 255.
self.set_speed(print_time, value)
self._delayed_set_speed(value)
def cmd_M107(self, params):
# Turn fan off
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
self.set_speed(print_time, 0.)
self._delayed_set_speed(0.)
def load_config(config):
return PrinterFan(config)