mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-05 04:54:11 -06:00
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>
This commit is contained in:
parent
ff9605c082
commit
adf6040e9e
4 changed files with 17 additions and 11 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue