diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-02-25 21:26:27 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-02-25 21:26:27 -0500 |
commit | adf6040e9eeb09299379ad980f8382538c163750 (patch) | |
tree | 349aa2a0d5fd4ac6948f580acd6b1b62607552f5 /klippy/extras/fan.py | |
parent | ff9605c082b79f4054d57ee660f909b5b2a90010 (diff) | |
download | kutter-adf6040e9eeb09299379ad980f8382538c163750.tar.gz kutter-adf6040e9eeb09299379ad980f8382538c163750.tar.xz kutter-adf6040e9eeb09299379ad980f8382538c163750.zip |
gcode: Use an event to handle restart request actions
Instead of directly turning off motors, heaters, and fans from
gcode.py, raise a new event and allow the heater, fan, and toolhead to
handle the event as needed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/fan.py')
-rw-r--r-- | klippy/extras/fan.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/klippy/extras/fan.py b/klippy/extras/fan.py index d69c1127..1796f636 100644 --- a/klippy/extras/fan.py +++ b/klippy/extras/fan.py @@ -10,9 +10,12 @@ class PrinterFan: def __init__(self, config, default_shutdown_speed=0.): self.last_fan_value = 0. self.last_fan_time = 0. + printer = config.get_printer() + printer.register_event_handler("gcode:request_restart", + self.handle_request_restart) self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.) self.kick_start_time = config.getfloat('kick_start_time', 0.1, minval=0.) - ppins = config.get_printer().lookup_object('pins') + ppins = printer.lookup_object('pins') self.mcu_fan = ppins.setup_pin('pwm', config.get('pin')) self.mcu_fan.setup_max_duration(0.) cycle_time = config.getfloat('cycle_time', 0.010, above=0.) @@ -22,6 +25,8 @@ class PrinterFan: 'shutdown_speed', default_shutdown_speed, minval=0., maxval=1.) self.mcu_fan.setup_start_value( 0., max(0., min(self.max_power, shutdown_speed))) + def handle_request_restart(self, print_time): + self.set_speed(print_time, 0.) def set_speed(self, print_time, value): value = max(0., min(self.max_power, value * self.max_power)) if value == self.last_fan_value: |