From 58a0eb76c5c3bbd24fec1aee8e6edd334702afd1 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 29 Mar 2021 14:23:46 -0400 Subject: [PATCH] homing: Pass the HomingMove class to homing_move_begin/end events Signed-off-by: Kevin O'Connor --- klippy/extras/bltouch.py | 4 ++-- klippy/extras/homing.py | 8 ++++---- klippy/extras/homing_heaters.py | 8 ++++---- klippy/extras/probe.py | 16 ++++++++-------- klippy/extras/tmc.py | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/klippy/extras/bltouch.py b/klippy/extras/bltouch.py index c8deee4b..6646433d 100644 --- a/klippy/extras/bltouch.py +++ b/klippy/extras/bltouch.py @@ -177,7 +177,7 @@ class BLTouchEndstopWrapper: self.raise_probe() self.sync_print_time() self.multi = 'OFF' - def probe_prepare(self): + def probe_prepare(self, hmove): if self.multi == 'OFF' or self.multi == 'FIRST': self.lower_probe() if self.multi == 'FIRST': @@ -187,7 +187,7 @@ class BLTouchEndstopWrapper: toolhead.flush_step_generation() self.start_mcu_pos = [(s, s.get_mcu_position()) for s in self.mcu_endstop.get_steppers()] - def probe_finish(self): + def probe_finish(self, hmove): if self.multi == 'OFF': self.raise_probe() self.sync_print_time() diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py index ffcd5a20..a1167e2e 100644 --- a/klippy/extras/homing.py +++ b/klippy/extras/homing.py @@ -25,6 +25,8 @@ class HomingMove: toolhead = printer.lookup_object('toolhead') self.toolhead = toolhead self.end_mcu_pos = [] + def get_mcu_endstops(self): + return [es for es, name in self.endstops] def _calc_endstop_rate(self, mcu_endstop, movepos, speed): startpos = self.toolhead.get_position() axes_d = [mp - sp for mp, sp in zip(movepos, startpos)] @@ -40,8 +42,7 @@ class HomingMove: def homing_move(self, movepos, speed, probe_pos=False, triggered=True, check_triggered=True): # Notify start of homing/probing move - self.printer.send_event("homing:homing_move_begin", - [es for es, name in self.endstops]) + self.printer.send_event("homing:homing_move_begin", self) # Note start location self.toolhead.flush_step_generation() kin = self.toolhead.get_kinematics() @@ -85,8 +86,7 @@ class HomingMove: self.toolhead.set_position(movepos) # Signal homing/probing move complete try: - self.printer.send_event("homing:homing_move_end", - [es for es, name in self.endstops]) + self.printer.send_event("homing:homing_move_end", self) except self.printer.command_error as e: if error is None: error = str(e) diff --git a/klippy/extras/homing_heaters.py b/klippy/extras/homing_heaters.py index 0ac32644..ea8c7df3 100644 --- a/klippy/extras/homing_heaters.py +++ b/klippy/extras/homing_heaters.py @@ -52,15 +52,15 @@ class HomingHeaters: for es in endstops for s in es.get_steppers()] return any(x in self.flaky_steppers for x in steppers_being_homed) - def handle_homing_move_begin(self, endstops): - if not self.check_eligible(endstops): + def handle_homing_move_begin(self, hmove): + if not self.check_eligible(hmove.get_mcu_endstops()): return for heater_name in self.disable_heaters: heater = self.pheaters.lookup_heater(heater_name) self.target_save[heater_name] = heater.get_temp(0)[1] heater.set_temp(0.) - def handle_homing_move_end(self, endstops): - if not self.check_eligible(endstops): + def handle_homing_move_end(self, hmove): + if not self.check_eligible(hmove.get_mcu_endstops()): return for heater_name in self.disable_heaters: heater = self.pheaters.lookup_heater(heater_name) diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index 7b4ddcb7..e4f7a9ac 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -70,12 +70,12 @@ class PrinterProbe: desc=self.cmd_PROBE_CALIBRATE_help) self.gcode.register_command('PROBE_ACCURACY', self.cmd_PROBE_ACCURACY, desc=self.cmd_PROBE_ACCURACY_help) - def _handle_homing_move_begin(self, endstops): - if self.mcu_probe in endstops: - self.mcu_probe.probe_prepare() - def _handle_homing_move_end(self, endstops): - if self.mcu_probe in endstops: - self.mcu_probe.probe_finish() + def _handle_homing_move_begin(self, hmove): + if self.mcu_probe in hmove.get_mcu_endstops(): + self.mcu_probe.probe_prepare(hmove) + def _handle_homing_move_end(self, hmove): + if self.mcu_probe in hmove.get_mcu_endstops(): + self.mcu_probe.probe_finish(hmove) def _handle_home_rails_begin(self, homing_state, rails): endstops = [es for rail in rails for es, name in rail.get_endstops()] if self.mcu_probe in endstops: @@ -296,14 +296,14 @@ class ProbeEndstopWrapper: pass def multi_probe_end(self): pass - def probe_prepare(self): + def probe_prepare(self, hmove): toolhead = self.printer.lookup_object('toolhead') start_pos = toolhead.get_position() self.activate_gcode.run_gcode_from_command() if toolhead.get_position()[:3] != start_pos[:3]: raise self.printer.command_error( "Toolhead moved during probe activate_gcode script") - def probe_finish(self): + def probe_finish(self, hmove): toolhead = self.printer.lookup_object('toolhead') start_pos = toolhead.get_position() self.deactivate_gcode.run_gcode_from_command() diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py index 449fae6e..6868b994 100644 --- a/klippy/extras/tmc.py +++ b/klippy/extras/tmc.py @@ -360,8 +360,8 @@ class TMCVirtualPinHelper: self.handle_homing_move_end) self.mcu_endstop = ppins.setup_pin('endstop', self.diag_pin) return self.mcu_endstop - def handle_homing_move_begin(self, endstops): - if self.mcu_endstop not in endstops: + def handle_homing_move_begin(self, hmove): + if self.mcu_endstop not in hmove.get_mcu_endstops(): return reg = self.fields.lookup_register("en_pwm_mode", None) if reg is None: @@ -376,8 +376,8 @@ class TMCVirtualPinHelper: self.mcu_tmc.set_register("GCONF", val) tc_val = self.fields.set_field("TCOOLTHRS", 0xfffff) self.mcu_tmc.set_register("TCOOLTHRS", tc_val) - def handle_homing_move_end(self, endstops): - if self.mcu_endstop not in endstops: + def handle_homing_move_end(self, hmove): + if self.mcu_endstop not in hmove.get_mcu_endstops(): return reg = self.fields.lookup_register("en_pwm_mode", None) if reg is None: