Skip to content

Commit

Permalink
also separate min_home_dist out
Browse files Browse the repository at this point in the history
  • Loading branch information
bwnance committed Nov 6, 2023
1 parent d731f23 commit 0a31345
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions klippy/extras/homing.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,20 @@ 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
startpos = self._fill_coord(forcepos)
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)
]
Expand Down
5 changes: 5 additions & 0 deletions klippy/stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,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
Expand Down Expand Up @@ -493,6 +496,7 @@ def get_homing_info(self):
"positive_dir",
"second_homing_speed",
"use_sensorless_homing",
"min_home_dist",
],
)(
self.homing_speed,
Expand All @@ -502,6 +506,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

Expand Down

0 comments on commit 0a31345

Please sign in to comment.