From f3e89e25c5ff3ec9c5499c186af4c28b6a9ab1f4 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 6 Apr 2025 11:14:13 -0400 Subject: force_move: Support a SET_HOMED parameter to SET_KINEMATIC_POSITION Commit 70838797 added support for clearing the homing state in SET_KINEMATIC_POSITION commands. However, it can be difficult to use that support as the default for SET_KINEMATIC_POSITION is to set all axes as homed. Add a new SET_HOMED parameter to allow one to explicitly request which axes to consider in a homed state. Also introduce a CLEAR_HOMED parameter and prefer that to the existing CLEAR parameter. Signed-off-by: Kevin O'Connor --- klippy/extras/force_move.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'klippy/extras') diff --git a/klippy/extras/force_move.py b/klippy/extras/force_move.py index 24783c2c..ad27f95c 100644 --- a/klippy/extras/force_move.py +++ b/klippy/extras/force_move.py @@ -131,12 +131,19 @@ class ForceMove: 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', '').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, clear_axes) - toolhead.set_position([x, y, z, curpos[3]], homing_axes="xyz") - toolhead.get_kinematics().clear_homing_state(clear_axes) + set_homed = gcmd.get('SET_HOMED', 'xyz').lower() + set_homed_axes = "".join([a for a in "xyz" if a in set_homed]) + if gcmd.get('CLEAR_HOMED', None) is None: + # "CLEAR" is an alias for "CLEAR_HOMED"; should deprecate + clear_homed = gcmd.get('CLEAR', '').lower() + else: + clear_homed = gcmd.get('CLEAR_HOMED', '') + clear_homed_axes = "".join([a for a in "xyz" if a in clear_homed]) + logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f" + " set_homed=%s clear_homed=%s", + x, y, z, set_homed_axes, clear_homed_axes) + toolhead.set_position([x, y, z, curpos[3]], homing_axes=set_homed_axes) + toolhead.get_kinematics().clear_homing_state(clear_homed_axes) def load_config(config): return ForceMove(config) -- cgit v1.2.3-70-g09d2