From e5765713407868bbe4ec949cd0241e2aca2f005c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 2 Jan 2020 19:46:06 -0500 Subject: [PATCH] fan: Do not flush look-ahead queue on fan speed change Signed-off-by: Kevin O'Connor --- klippy/extras/fan.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py index 571d7052..f8c32562 100644 --- a/klippy/extras/fan.py +++ b/klippy/extras/fan.py @@ -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)