aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2025-04-30 19:18:50 -0400
committerKevin O'Connor <kevin@koconnor.net>2025-05-12 20:15:03 -0400
commitee0bc3d697a136ff9dea2107430d703c421ba4f9 (patch)
tree9700d35db7c3cd47961e3468557272aa938a7966
parent64e01f03a20f4d895f4baa5d5f72870f800f5830 (diff)
downloadkutter-ee0bc3d697a136ff9dea2107430d703c421ba4f9.tar.gz
kutter-ee0bc3d697a136ff9dea2107430d703c421ba4f9.tar.xz
kutter-ee0bc3d697a136ff9dea2107430d703c421ba4f9.zip
manual_stepper: Support position_min and position_max options
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--docs/Config_Reference.md7
-rw-r--r--klippy/extras/manual_stepper.py14
2 files changed, 19 insertions, 2 deletions
diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md
index f9ef676b..2f4b714d 100644
--- a/docs/Config_Reference.md
+++ b/docs/Config_Reference.md
@@ -2540,6 +2540,13 @@ printer kinematics.
# Endstop switch detection pin. If specified, then one may perform
# "homing moves" by adding a STOP_ON_ENDSTOP parameter to
# MANUAL_STEPPER movement commands.
+#position_min:
+#position_max:
+# The minimum and maximum position the stepper can be commanded to
+# move to. If specified then one may not command the stepper to move
+# past the given position. Note that these limits do not prevent
+# setting an arbitrary position with the `MANUAL_STEPPER
+# SET_POSITION=x` command. The default is to not enforce a limit.
```
## Custom heaters and sensors
diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py
index 6e02ee86..4c55deb8 100644
--- a/klippy/extras/manual_stepper.py
+++ b/klippy/extras/manual_stepper.py
@@ -22,6 +22,8 @@ class ManualStepper:
self.velocity = config.getfloat('velocity', 5., above=0.)
self.accel = self.homing_accel = config.getfloat('accel', 0., minval=0.)
self.next_cmd_time = 0.
+ self.pos_min = config.getfloat('position_min', None)
+ self.pos_max = config.getfloat('position_max', None)
# Setup iterative solver
ffi_main, ffi_lib = chelper.get_ffi()
self.trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free)
@@ -107,10 +109,16 @@ class ManualStepper:
homing_move = gcmd.get_int('STOP_ON_ENDSTOP', 0)
if homing_move:
movepos = gcmd.get_float('MOVE')
+ if ((self.pos_min is not None and movepos < self.pos_min)
+ or (self.pos_max is not None and movepos > self.pos_max)):
+ raise gcmd.error("Move out of range")
self.do_homing_move(movepos, speed, accel,
homing_move > 0, abs(homing_move) == 1)
elif gcmd.get_float('MOVE', None) is not None:
movepos = gcmd.get_float('MOVE')
+ if ((self.pos_min is not None and movepos < self.pos_min)
+ or (self.pos_max is not None and movepos > self.pos_max)):
+ raise gcmd.error("Move out of range")
sync = gcmd.get_int('SYNC', 1)
self.do_move(movepos, speed, accel, sync)
elif gcmd.get_int('SYNC', 0):
@@ -155,10 +163,12 @@ class ManualStepper:
1., 0., 0.,
start_v, cruise_v, accel)
def check_move(self, move, ea_index):
- # XXX - support out of bounds checks
+ movepos = move.end_pos[ea_index]
+ if ((self.pos_min is not None and movepos < self.pos_min)
+ or (self.pos_max is not None and movepos > self.pos_max)):
+ raise move.move_error()
# XXX - support max accel/velocity
# XXX - support non-kinematic max accel/velocity
- pass
def calc_junction(self, prev_move, move, ea_index):
diff_r = move.axes_r[ea_index] - prev_move.axes_r[ea_index]
if diff_r: