Skip to content

Commit 6ab2533

Browse files
committed
force_move: Use strings for axes to clear in clear_homing_state()
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]>
1 parent 4aa5508 commit 6ab2533

14 files changed

+38
-39
lines changed

klippy/extras/force_move.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,10 @@ def cmd_SET_KINEMATIC_POSITION(self, gcmd):
131131
x = gcmd.get_float('X', curpos[0])
132132
y = gcmd.get_float('Y', curpos[1])
133133
z = gcmd.get_float('Z', curpos[2])
134-
clear = gcmd.get('CLEAR', '').upper()
135-
axes = ['X', 'Y', 'Z']
136-
clear_axes = [axes.index(a) for a in axes if a in clear]
134+
clear = gcmd.get('CLEAR', '').lower()
135+
clear_axes = "".join([a for a in "xyz" if a in clear])
137136
logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f clear=%s",
138-
x, y, z, ','.join((axes[i] for i in clear_axes)))
137+
x, y, z, clear_axes)
139138
toolhead.set_position([x, y, z, curpos[3]], homing_axes="xyz")
140139
toolhead.get_kinematics().clear_homing_state(clear_axes)
141140

klippy/extras/safe_z_home.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def cmd_G28(self, gcmd):
4040
toolhead.set_position(pos, homing_axes="z")
4141
toolhead.manual_move([None, None, self.z_hop],
4242
self.z_hop_speed)
43-
toolhead.get_kinematics().clear_homing_state((2,))
43+
toolhead.get_kinematics().clear_homing_state("z")
4444
elif pos[2] < self.z_hop:
4545
# If the Z axis is homed, and below z_hop, lift it to z_hop
4646
toolhead.manual_move([None, None, self.z_hop],

klippy/extras/stepper_enable.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def motor_off(self):
9494
print_time = toolhead.get_last_move_time()
9595
for el in self.enable_lines.values():
9696
el.motor_disable(print_time)
97-
toolhead.get_kinematics().clear_homing_state((0, 1, 2))
97+
toolhead.get_kinematics().clear_homing_state("xyz")
9898
self.printer.send_event("stepper_enable:motor_off", print_time)
9999
toolhead.dwell(DISABLE_STALL_TIME)
100100
def motor_debug_enable(self, stepper, enable):

klippy/kinematics/cartesian.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ def set_position(self, newpos, homing_axes):
7272
else:
7373
rail = self.rails[axis]
7474
self.limits[axis] = rail.get_range()
75-
def clear_homing_state(self, axes):
76-
for i, _ in enumerate(self.limits):
77-
if i in axes:
78-
self.limits[i] = (1.0, -1.0)
75+
def clear_homing_state(self, clear_axes):
76+
for axis, axis_name in enumerate("xyz"):
77+
if axis_name in clear_axes:
78+
self.limits[axis] = (1.0, -1.0)
7979
def home_axis(self, homing_state, axis, rail):
8080
# Determine movement
8181
position_min, position_max = rail.get_range()

klippy/kinematics/corexy.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def set_position(self, newpos, homing_axes):
4141
rail.set_position(newpos)
4242
if "xyz"[i] in homing_axes:
4343
self.limits[i] = rail.get_range()
44-
def clear_homing_state(self, axes):
45-
for i, _ in enumerate(self.limits):
46-
if i in axes:
47-
self.limits[i] = (1.0, -1.0)
44+
def clear_homing_state(self, clear_axes):
45+
for axis, axis_name in enumerate("xyz"):
46+
if axis_name in clear_axes:
47+
self.limits[axis] = (1.0, -1.0)
4848
def home(self, homing_state):
4949
# Each axis is homed independently and in order
5050
for axis in homing_state.get_axes():

klippy/kinematics/corexz.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def set_position(self, newpos, homing_axes):
4141
rail.set_position(newpos)
4242
if "xyz"[i] in homing_axes:
4343
self.limits[i] = rail.get_range()
44-
def clear_homing_state(self, axes):
45-
for i, _ in enumerate(self.limits):
46-
if i in axes:
47-
self.limits[i] = (1.0, -1.0)
44+
def clear_homing_state(self, clear_axes):
45+
for axis, axis_name in enumerate("xyz"):
46+
if axis_name in clear_axes:
47+
self.limits[axis] = (1.0, -1.0)
4848
def home(self, homing_state):
4949
# Each axis is homed independently and in order
5050
for axis in homing_state.get_axes():

klippy/kinematics/delta.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def set_position(self, newpos, homing_axes):
103103
self.limit_xy2 = -1.
104104
if homing_axes == "xyz":
105105
self.need_home = False
106-
def clear_homing_state(self, axes):
106+
def clear_homing_state(self, clear_axes):
107107
# Clearing homing state for each axis individually is not implemented
108-
if 0 in axes or 1 in axes or 2 in axes:
108+
if clear_axes:
109109
self.limit_xy2 = -1
110110
self.need_home = True
111111
def home(self, homing_state):

klippy/kinematics/deltesian.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ def set_position(self, newpos, homing_axes):
116116
for axis_name in homing_axes:
117117
axis = "xyz".index(axis_name)
118118
self.homed_axis[axis] = True
119-
def clear_homing_state(self, axes):
120-
for i, _ in enumerate(self.limits):
121-
if i in axes:
122-
self.homed_axis[i] = False
119+
def clear_homing_state(self, clear_axes):
120+
for axis, axis_name in enumerate("xyz"):
121+
if axis_name in clear_axes:
122+
self.homed_axis[axis] = False
123123
def home(self, homing_state):
124124
homing_axes = homing_state.get_axes()
125125
home_xz = 0 in homing_axes or 2 in homing_axes

klippy/kinematics/hybrid_corexy.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ def set_position(self, newpos, homing_axes):
7474
else:
7575
rail = self.rails[axis]
7676
self.limits[axis] = rail.get_range()
77-
def clear_homing_state(self, axes):
78-
for i, _ in enumerate(self.limits):
79-
if i in axes:
80-
self.limits[i] = (1.0, -1.0)
77+
def clear_homing_state(self, clear_axes):
78+
for axis, axis_name in enumerate("xyz"):
79+
if axis_name in clear_axes:
80+
self.limits[axis] = (1.0, -1.0)
8181
def home_axis(self, homing_state, axis, rail):
8282
position_min, position_max = rail.get_range()
8383
hi = rail.get_homing_info()

klippy/kinematics/hybrid_corexz.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ def set_position(self, newpos, homing_axes):
7474
else:
7575
rail = self.rails[axis]
7676
self.limits[axis] = rail.get_range()
77-
def clear_homing_state(self, axes):
78-
for i, _ in enumerate(self.limits):
79-
if i in axes:
80-
self.limits[i] = (1.0, -1.0)
77+
def clear_homing_state(self, clear_axes):
78+
for axis, axis_name in enumerate("xyz"):
79+
if axis_name in clear_axes:
80+
self.limits[axis] = (1.0, -1.0)
8181
def home_axis(self, homing_state, axis, rail):
8282
position_min, position_max = rail.get_range()
8383
hi = rail.get_homing_info()

klippy/kinematics/none.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def calc_position(self, stepper_positions):
1313
return [0, 0, 0]
1414
def set_position(self, newpos, homing_axes):
1515
pass
16-
def clear_homing_state(self, axes):
16+
def clear_homing_state(self, clear_axes):
1717
pass
1818
def home(self, homing_state):
1919
pass

klippy/kinematics/polar.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def set_position(self, newpos, homing_axes):
4949
self.limit_z = self.rails[1].get_range()
5050
if "x" in homing_axes and "y" in homing_axes:
5151
self.limit_xy2 = self.rails[0].get_range()[1]**2
52-
def clear_homing_state(self, axes):
53-
if 0 in axes or 1 in axes:
52+
def clear_homing_state(self, clear_axes):
53+
if "x" in clear_axes or "y" in clear_axes:
5454
# X and Y cannot be cleared separately
5555
self.limit_xy2 = -1.
56-
if 2 in axes:
56+
if "z" in clear_axes:
5757
self.limit_z = (1.0, -1.0)
5858
def _home_axis(self, homing_state, axis, rail):
5959
# Determine movement

klippy/kinematics/rotary_delta.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def set_position(self, newpos, homing_axes):
8686
self.limit_xy2 = -1.
8787
if homing_axes == "xyz":
8888
self.need_home = False
89-
def clear_homing_state(self, axes):
89+
def clear_homing_state(self, clear_axes):
9090
# Clearing homing state for each axis individually is not implemented
91-
if 0 in axes or 1 in axes or 2 in axes:
91+
if clear_axes:
9292
self.limit_xy2 = -1
9393
self.need_home = True
9494
def home(self, homing_state):

klippy/kinematics/winch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def calc_position(self, stepper_positions):
3636
def set_position(self, newpos, homing_axes):
3737
for s in self.steppers:
3838
s.set_position(newpos)
39-
def clear_homing_state(self, axes):
39+
def clear_homing_state(self, clear_axes):
4040
# XXX - homing not implemented
4141
pass
4242
def home(self, homing_state):

0 commit comments

Comments
 (0)