From 4dcd6870d680d20a6826fe280a0c7082b3e87e12 Mon Sep 17 00:00:00 2001 From: Brandon Nance Date: Sun, 5 Nov 2023 22:21:24 -0500 Subject: [PATCH] also separate min_home_dist out --- klippy/extras/homing.py | 6 ++++-- klippy/stepper.py | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py index b861564d8..c928efd83 100644 --- a/klippy/extras/homing.py +++ b/klippy/extras/homing.py @@ -284,10 +284,12 @@ def home_rails(self, rails, forcepos, movepos): # Perform second home if hi.retract_dist: needs_rehome = False + retract_dist = hi.retract_dist if any( - [abs(dist) < hi.retract_dist for dist in homing_axis_distances] + [abs(dist) < hi.min_home_dist for dist in homing_axis_distances] ): needs_rehome = True + retract_dist = hi.min_home_dist logging.info("needs rehome: %s", needs_rehome) # Retract @@ -295,7 +297,7 @@ def home_rails(self, rails, forcepos, movepos): homepos = self._fill_coord(movepos) axes_d = [hp - sp for hp, sp in zip(homepos, startpos)] move_d = math.sqrt(sum([d * d for d in axes_d[:3]])) - retract_r = min(1.0, hi.retract_dist / move_d) + retract_r = min(1.0, retract_dist / move_d) retractpos = [ hp - ad * retract_r for hp, ad in zip(homepos, axes_d) ] diff --git a/klippy/stepper.py b/klippy/stepper.py index 49b0685d0..e0b5d3599 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -479,6 +479,9 @@ def __init__( self.use_sensorless_homing = config.getboolean( "use_sensorless_homing", endstop_is_virtual ) + self.min_home_dist = config.getfloat( + "min_home_dist", self.homing_retract_dist, minval=0.0 + ) if self.homing_positive_dir is None: axis_len = self.position_max - self.position_min @@ -518,6 +521,7 @@ def get_homing_info(self): "positive_dir", "second_homing_speed", "use_sensorless_homing", + "min_home_dist", ], )( self.homing_speed, @@ -527,6 +531,7 @@ def get_homing_info(self): self.homing_positive_dir, self.second_homing_speed, self.use_sensorless_homing, + self.min_home_dist, ) return homing_info