klippy: Convert printer_state("connect") to an event handler

Convert all users of the printer_state("connect") handler to register
a "klippy:connect" event handler instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-01-08 11:09:55 -05:00
parent 797367b9f5
commit 857e7ed5f1
8 changed files with 32 additions and 37 deletions

View file

@ -53,6 +53,8 @@ class BedMesh:
FADE_DISABLE = 0x7FFFFFFF
def __init__(self, config):
self.printer = config.get_printer()
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
self.last_position = [0., 0., 0., 0.]
self.calibrate = BedMeshCalibrate(config, self)
self.z_mesh = None
@ -74,10 +76,9 @@ class BedMesh:
'BED_MESH_CLEAR', self.cmd_BED_MESH_CLEAR,
desc=self.cmd_BED_MESH_CLEAR_help)
self.gcode.set_move_transform(self)
def printer_state(self, state):
if state == 'connect':
self.toolhead = self.printer.lookup_object('toolhead')
self.calibrate.load_default_profile()
def handle_connect(self):
self.toolhead = self.printer.lookup_object('toolhead')
self.calibrate.load_default_profile()
def set_mesh(self, mesh):
if mesh is not None:
if self.base_fade_target is None: