aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/heater.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-02-25 21:26:27 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-02-25 21:26:27 -0500
commitadf6040e9eeb09299379ad980f8382538c163750 (patch)
tree349aa2a0d5fd4ac6948f580acd6b1b62607552f5 /klippy/heater.py
parentff9605c082b79f4054d57ee660f909b5b2a90010 (diff)
downloadkutter-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/heater.py')
-rw-r--r--klippy/heater.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/klippy/heater.py b/klippy/heater.py
index 1d48c5a3..18a1d67b 100644
--- a/klippy/heater.py
+++ b/klippy/heater.py
@@ -230,6 +230,8 @@ class PrinterHeaters:
self.sensor_factories = {}
self.heaters = {}
self.gcode_id_to_sensor = {}
+ self.printer.register_event_handler("gcode:request_restart",
+ self.turn_off_all_heaters)
# Register TURN_OFF_HEATERS command
gcode = self.printer.lookup_object('gcode')
gcode.register_command("TURN_OFF_HEATERS", self.cmd_TURN_OFF_HEATERS,
@@ -265,15 +267,15 @@ class PrinterHeaters:
raise self.printer.config_error(
"Unknown temperature sensor '%s'" % (sensor_type,))
return self.sensor_factories[sensor_type](config)
- def get_all_heaters(self):
- return self.heaters.values()
def get_gcode_sensors(self):
return self.gcode_id_to_sensor.items()
+ def turn_off_all_heaters(self, print_time):
+ for heater in self.heaters.values():
+ heater.set_temp(print_time, 0.)
cmd_TURN_OFF_HEATERS_help = "Turn off all heaters"
def cmd_TURN_OFF_HEATERS(self, params):
print_time = self.printer.lookup_object('toolhead').get_last_move_time()
- for heater in self.heaters.values():
- heater.set_temp(print_time, 0.)
+ self.turn_off_all_heaters(print_time)
def add_printer_objects(config):
config.get_printer().add_object('heater', PrinterHeaters(config))