aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepper.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-05-18 19:34:17 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-05-18 19:41:03 -0400
commit11816295e798f841a5b06447daba6bafc258af55 (patch)
tree7a984e918482143c20df21b3fb9a66fb0b858844 /klippy/stepper.py
parent2740838b2ef9bbf661de8a192b831990a5c08e38 (diff)
downloadkutter-11816295e798f841a5b06447daba6bafc258af55.tar.gz
kutter-11816295e798f841a5b06447daba6bafc258af55.tar.xz
kutter-11816295e798f841a5b06447daba6bafc258af55.zip
stepper: Raise an error if position_endstop is not in min/max range
Raise an error during config parsing if the position_endstop is not between the position_min and position_max. This avoids a confusing error message during homing. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepper.py')
-rw-r--r--klippy/stepper.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/klippy/stepper.py b/klippy/stepper.py
index 2bad5e8a..8767fd12 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -71,21 +71,31 @@ class PrinterStepper:
# Support for stepper controlled linear axis with an endstop
class PrinterHomingStepper(PrinterStepper):
- def __init__(self, printer, config, default_position=None):
+ def __init__(self, printer, config, need_position_minmax=True,
+ default_position_endstop=None):
PrinterStepper.__init__(self, printer, config)
# Endstop and its position
ppins = printer.lookup_object('pins')
self.mcu_endstop = ppins.setup_pin('endstop', config.get('endstop_pin'))
self.mcu_endstop.add_stepper(self.mcu_stepper)
- if default_position is None:
+ if default_position_endstop is None:
self.position_endstop = config.getfloat('position_endstop')
else:
self.position_endstop = config.getfloat(
- 'position_endstop', default_position)
+ 'position_endstop', default_position_endstop)
# Axis range
- self.position_min = config.getfloat('position_min', 0.)
- self.position_max = config.getfloat(
- 'position_max', 0., above=self.position_min)
+ if need_position_minmax:
+ self.position_min = config.getfloat('position_min', 0.)
+ self.position_max = config.getfloat(
+ 'position_max', above=self.position_min)
+ else:
+ self.position_min = 0.
+ self.position_max = self.position_endstop
+ if (self.position_endstop < self.position_min
+ or self.position_endstop > self.position_max):
+ raise config.error(
+ "position_endstop in section '%s' must be between"
+ " position_min and position_max" % config.get_name())
# Homing mechanics
self.homing_speed = config.getfloat('homing_speed', 5.0, above=0.)
self.homing_retract_dist = config.getfloat(