From adf6040e9eeb09299379ad980f8382538c163750 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 25 Feb 2019 21:26:27 -0500 Subject: 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 --- klippy/toolhead.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'klippy/toolhead.py') diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 32bda0fc..9629dc8f 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -205,6 +205,8 @@ class ToolHead: self.mcu = self.all_mcus[0] self.move_queue = MoveQueue() self.commanded_pos = [0., 0., 0., 0.] + self.printer.register_event_handler("gcode:request_restart", + self._handle_request_restart) self.printer.register_event_handler("klippy:shutdown", self._handle_shutdown) # Velocity and acceleration control @@ -416,6 +418,8 @@ class ToolHead: return { 'status': status, 'print_time': print_time, 'estimated_print_time': estimated_print_time, 'printing_time': print_time - last_print_start_time } + def _handle_request_restart(self, print_time): + self.motor_off() def _handle_shutdown(self): self.move_queue.reset() self.reset_print_time() -- cgit v1.2.3-70-g09d2