diff options
Diffstat (limited to 'klippy/extras/fan_generic.py')
-rw-r--r-- | klippy/extras/fan_generic.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/klippy/extras/fan_generic.py b/klippy/extras/fan_generic.py index f8ad996f..3a9b3791 100644 --- a/klippy/extras/fan_generic.py +++ b/klippy/extras/fan_generic.py @@ -6,34 +6,41 @@ import logging from . import fan, output_pin + class PrinterFanGeneric: cmd_SET_FAN_SPEED_help = "Sets the speed of a fan" + def __init__(self, config): self.printer = config.get_printer() - self.fan = fan.Fan(config, default_shutdown_speed=0.) + self.fan = fan.Fan(config, default_shutdown_speed=0.0) self.fan_name = config.get_name().split()[-1] # Template handling self.template_eval = output_pin.lookup_template_eval(config) gcode = self.printer.lookup_object("gcode") - gcode.register_mux_command("SET_FAN_SPEED", "FAN", - self.fan_name, - self.cmd_SET_FAN_SPEED, - desc=self.cmd_SET_FAN_SPEED_help) + gcode.register_mux_command( + "SET_FAN_SPEED", + "FAN", + self.fan_name, + self.cmd_SET_FAN_SPEED, + desc=self.cmd_SET_FAN_SPEED_help, + ) def get_status(self, eventtime): return self.fan.get_status(eventtime) + def _template_update(self, text): try: value = float(text) except ValueError as e: logging.exception("fan_generic template render error") - value = 0. + value = 0.0 self.fan.set_speed(value) + def cmd_SET_FAN_SPEED(self, gcmd): - speed = gcmd.get_float('SPEED', None, 0.) - template = gcmd.get('TEMPLATE', None) + speed = gcmd.get_float("SPEED", None, 0.0) + template = gcmd.get("TEMPLATE", None) if (speed is None) == (template is None): raise gcmd.error("SET_FAN_SPEED must specify SPEED or TEMPLATE") # Check for template setting @@ -42,5 +49,6 @@ class PrinterFanGeneric: return self.fan.set_speed_from_command(speed) + def load_config_prefix(config): return PrinterFanGeneric(config) |