mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-10-26 15:56:10 +01:00
klippy: Convert printer_state("disconnect") to an event handler
Convert all users of the printer_state("disconnect") handler to
register a "klippy:disconnect" event handler instead.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -423,6 +423,8 @@ class MCU:
|
||||
if self._name.startswith('mcu '):
|
||||
self._name = self._name[4:]
|
||||
self._printer.register_event_handler("klippy:shutdown", self._shutdown)
|
||||
self._printer.register_event_handler("klippy:disconnect",
|
||||
self._disconnect)
|
||||
# Serial port
|
||||
self._serialport = config.get('serial', '/dev/ttyS0')
|
||||
baud = 0
|
||||
@@ -768,8 +770,6 @@ class MCU:
|
||||
def printer_state(self, state):
|
||||
if state == 'connect':
|
||||
self._connect()
|
||||
elif state == 'disconnect':
|
||||
self._disconnect()
|
||||
def __del__(self):
|
||||
self._disconnect()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user