diff options
Diffstat (limited to 'klippy/extras/heater_fan.py')
-rw-r--r-- | klippy/extras/heater_fan.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/klippy/extras/heater_fan.py b/klippy/extras/heater_fan.py index 3630366e..6aa8ecc5 100644 --- a/klippy/extras/heater_fan.py +++ b/klippy/extras/heater_fan.py @@ -7,26 +7,30 @@ from . import fan PIN_MIN_TIME = 0.100 + class PrinterHeaterFan: def __init__(self, config): self.printer = config.get_printer() - self.printer.load_object(config, 'heaters') + self.printer.load_object(config, "heaters") self.printer.register_event_handler("klippy:ready", self.handle_ready) self.heater_names = config.getlist("heater", ("extruder",)) self.heater_temp = config.getfloat("heater_temp", 50.0) self.heaters = [] - self.fan = fan.Fan(config, default_shutdown_speed=1.) - self.fan_speed = config.getfloat("fan_speed", 1., minval=0., maxval=1.) - self.last_speed = 0. + self.fan = fan.Fan(config, default_shutdown_speed=1.0) + self.fan_speed = config.getfloat("fan_speed", 1.0, minval=0.0, maxval=1.0) + self.last_speed = 0.0 + def handle_ready(self): - pheaters = self.printer.lookup_object('heaters') + pheaters = self.printer.lookup_object("heaters") self.heaters = [pheaters.lookup_heater(n) for n in self.heater_names] reactor = self.printer.get_reactor() - reactor.register_timer(self.callback, reactor.monotonic()+PIN_MIN_TIME) + reactor.register_timer(self.callback, reactor.monotonic() + PIN_MIN_TIME) + def get_status(self, eventtime): return self.fan.get_status(eventtime) + def callback(self, eventtime): - speed = 0. + speed = 0.0 for heater in self.heaters: current_temp, target_temp = heater.get_temp(eventtime) if target_temp or current_temp > self.heater_temp: @@ -34,7 +38,8 @@ class PrinterHeaterFan: if speed != self.last_speed: self.last_speed = speed self.fan.set_speed(speed) - return eventtime + 1. + return eventtime + 1.0 + def load_config_prefix(config): return PrinterHeaterFan(config) |