Skip to content

Commit

Permalink
force_move: Use strings for axes to clear in clear_homing_state()
Browse files Browse the repository at this point in the history
Pass a string such as "xyz" to kin.clear_homing_state().  This makes
the parameter a little less cryptic.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Jan 10, 2025
1 parent acf55d7 commit 3e62be4
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 38 deletions.
5 changes: 2 additions & 3 deletions klippy/extras/force_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ def cmd_SET_KINEMATIC_POSITION(self, gcmd):
x = gcmd.get_float('X', curpos[0])
y = gcmd.get_float('Y', curpos[1])
z = gcmd.get_float('Z', curpos[2])
clear = gcmd.get('CLEAR', '').upper()
axes = ['X', 'Y', 'Z']
clear_axes = [axes.index(a) for a in axes if a in clear]
clear = gcmd.get('CLEAR', '').lower()
clear_axes = "".join([a for a in "xyz" if a in clear])
logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f clear=%s",
x, y, z, ','.join((axes[i] for i in clear_axes)))
toolhead.set_position([x, y, z, curpos[3]], homing_axes="xyz")
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/safe_z_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def cmd_G28(self, gcmd):
toolhead.set_position(pos, homing_axes="z")
toolhead.manual_move([None, None, self.z_hop],
self.z_hop_speed)
toolhead.get_kinematics().clear_homing_state((2,))
toolhead.get_kinematics().clear_homing_state("z")
elif pos[2] < self.z_hop:
# If the Z axis is homed, and below z_hop, lift it to z_hop
toolhead.manual_move([None, None, self.z_hop],
Expand Down
2 changes: 1 addition & 1 deletion klippy/extras/stepper_enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def motor_off(self):
print_time = toolhead.get_last_move_time()
for el in self.enable_lines.values():
el.motor_disable(print_time)
toolhead.get_kinematics().clear_homing_state((0, 1, 2))
toolhead.get_kinematics().clear_homing_state("xyz")
self.printer.send_event("stepper_enable:motor_off", print_time)
toolhead.dwell(DISABLE_STALL_TIME)
def motor_debug_enable(self, stepper, enable):
Expand Down
8 changes: 4 additions & 4 deletions klippy/kinematics/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ def set_position(self, newpos, homing_axes):
else:
rail = self.rails[axis]
self.limits[axis] = rail.get_range()
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
if i in axes:
self.limits[i] = (1.0, -1.0)
def clear_homing_state(self, clear_axes):
for axis, axis_name in enumerate("xyz"):
if axis_name in clear_axes:
self.limits[axis] = (1.0, -1.0)
def home_axis(self, homing_state, axis, rail):
# Determine movement
position_min, position_max = rail.get_range()
Expand Down
8 changes: 4 additions & 4 deletions klippy/kinematics/corexy.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def set_position(self, newpos, homing_axes):
rail.set_position(newpos)
if "xyz"[i] in homing_axes:
self.limits[i] = rail.get_range()
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
if i in axes:
self.limits[i] = (1.0, -1.0)
def clear_homing_state(self, clear_axes):
for axis, axis_name in enumerate("xyz"):
if axis_name in clear_axes:
self.limits[axis] = (1.0, -1.0)
def home(self, homing_state):
# Each axis is homed independently and in order
for axis in homing_state.get_axes():
Expand Down
8 changes: 4 additions & 4 deletions klippy/kinematics/corexz.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def set_position(self, newpos, homing_axes):
rail.set_position(newpos)
if "xyz"[i] in homing_axes:
self.limits[i] = rail.get_range()
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
if i in axes:
self.limits[i] = (1.0, -1.0)
def clear_homing_state(self, clear_axes):
for axis, axis_name in enumerate("xyz"):
if axis_name in clear_axes:
self.limits[axis] = (1.0, -1.0)
def home(self, homing_state):
# Each axis is homed independently and in order
for axis in homing_state.get_axes():
Expand Down
4 changes: 2 additions & 2 deletions klippy/kinematics/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def set_position(self, newpos, homing_axes):
self.limit_xy2 = -1.
if homing_axes == "xyz":
self.need_home = False
def clear_homing_state(self, axes):
def clear_homing_state(self, clear_axes):
# Clearing homing state for each axis individually is not implemented
if 0 in axes or 1 in axes or 2 in axes:
if clear_axes:
self.limit_xy2 = -1
self.need_home = True
def home(self, homing_state):
Expand Down
8 changes: 4 additions & 4 deletions klippy/kinematics/deltesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ def set_position(self, newpos, homing_axes):
for axis_name in homing_axes:
axis = "xyz".index(axis_name)
self.homed_axis[axis] = True
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
if i in axes:
self.homed_axis[i] = False
def clear_homing_state(self, clear_axes):
for axis, axis_name in enumerate("xyz"):
if axis_name in clear_axes:
self.homed_axis[axis] = False
def home(self, homing_state):
homing_axes = homing_state.get_axes()
home_xz = 0 in homing_axes or 2 in homing_axes
Expand Down
8 changes: 4 additions & 4 deletions klippy/kinematics/hybrid_corexy.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ def set_position(self, newpos, homing_axes):
else:
rail = self.rails[axis]
self.limits[axis] = rail.get_range()
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
if i in axes:
self.limits[i] = (1.0, -1.0)
def clear_homing_state(self, clear_axes):
for axis, axis_name in enumerate("xyz"):
if axis_name in clear_axes:
self.limits[axis] = (1.0, -1.0)
def home_axis(self, homing_state, axis, rail):
position_min, position_max = rail.get_range()
hi = rail.get_homing_info()
Expand Down
8 changes: 4 additions & 4 deletions klippy/kinematics/hybrid_corexz.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ def set_position(self, newpos, homing_axes):
else:
rail = self.rails[axis]
self.limits[axis] = rail.get_range()
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
if i in axes:
self.limits[i] = (1.0, -1.0)
def clear_homing_state(self, clear_axes):
for axis, axis_name in enumerate("xyz"):
if axis_name in clear_axes:
self.limits[axis] = (1.0, -1.0)
def home_axis(self, homing_state, axis, rail):
position_min, position_max = rail.get_range()
hi = rail.get_homing_info()
Expand Down
2 changes: 1 addition & 1 deletion klippy/kinematics/none.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def calc_position(self, stepper_positions):
return [0, 0, 0]
def set_position(self, newpos, homing_axes):
pass
def clear_homing_state(self, axes):
def clear_homing_state(self, clear_axes):
pass
def home(self, homing_state):
pass
Expand Down
6 changes: 3 additions & 3 deletions klippy/kinematics/polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def set_position(self, newpos, homing_axes):
self.limit_z = self.rails[1].get_range()
if "x" in homing_axes and "y" in homing_axes:
self.limit_xy2 = self.rails[0].get_range()[1]**2
def clear_homing_state(self, axes):
if 0 in axes or 1 in axes:
def clear_homing_state(self, clear_axes):
if "x" in clear_axes or "y" in clear_axes:
# X and Y cannot be cleared separately
self.limit_xy2 = -1.
if 2 in axes:
if "z" in clear_axes:
self.limit_z = (1.0, -1.0)
def _home_axis(self, homing_state, axis, rail):
# Determine movement
Expand Down
4 changes: 2 additions & 2 deletions klippy/kinematics/rotary_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def set_position(self, newpos, homing_axes):
self.limit_xy2 = -1.
if homing_axes == "xyz":
self.need_home = False
def clear_homing_state(self, axes):
def clear_homing_state(self, clear_axes):
# Clearing homing state for each axis individually is not implemented
if 0 in axes or 1 in axes or 2 in axes:
if clear_axes:
self.limit_xy2 = -1
self.need_home = True
def home(self, homing_state):
Expand Down
2 changes: 1 addition & 1 deletion klippy/kinematics/winch.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def calc_position(self, stepper_positions):
def set_position(self, newpos, homing_axes):
for s in self.steppers:
s.set_position(newpos)
def clear_homing_state(self, axes):
def clear_homing_state(self, clear_axes):
# XXX - homing not implemented
pass
def home(self, homing_state):
Expand Down

0 comments on commit 3e62be4

Please sign in to comment.