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>
This commit is contained in:
parent
2740838b2e
commit
11816295e7
|
@ -15,13 +15,14 @@ class DeltaKinematics:
|
||||||
def __init__(self, toolhead, printer, config):
|
def __init__(self, toolhead, printer, config):
|
||||||
stepper_configs = [config.getsection('stepper_' + n)
|
stepper_configs = [config.getsection('stepper_' + n)
|
||||||
for n in ['a', 'b', 'c']]
|
for n in ['a', 'b', 'c']]
|
||||||
stepper_a = stepper.PrinterHomingStepper(printer, stepper_configs[0])
|
stepper_a = stepper.PrinterHomingStepper(
|
||||||
|
printer, stepper_configs[0], need_position_minmax = False)
|
||||||
stepper_b = stepper.PrinterHomingStepper(
|
stepper_b = stepper.PrinterHomingStepper(
|
||||||
printer, stepper_configs[1],
|
printer, stepper_configs[1], need_position_minmax = False,
|
||||||
default_position=stepper_a.position_endstop)
|
default_position_endstop=stepper_a.position_endstop)
|
||||||
stepper_c = stepper.PrinterHomingStepper(
|
stepper_c = stepper.PrinterHomingStepper(
|
||||||
printer, stepper_configs[2],
|
printer, stepper_configs[2], need_position_minmax = False,
|
||||||
default_position=stepper_a.position_endstop)
|
default_position_endstop=stepper_a.position_endstop)
|
||||||
self.steppers = [stepper_a, stepper_b, stepper_c]
|
self.steppers = [stepper_a, stepper_b, stepper_c]
|
||||||
self.need_motor_enable = self.need_home = True
|
self.need_motor_enable = self.need_home = True
|
||||||
self.radius = radius = config.getfloat('delta_radius', above=0.)
|
self.radius = radius = config.getfloat('delta_radius', above=0.)
|
||||||
|
|
|
@ -71,21 +71,31 @@ class PrinterStepper:
|
||||||
|
|
||||||
# Support for stepper controlled linear axis with an endstop
|
# Support for stepper controlled linear axis with an endstop
|
||||||
class PrinterHomingStepper(PrinterStepper):
|
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)
|
PrinterStepper.__init__(self, printer, config)
|
||||||
# Endstop and its position
|
# Endstop and its position
|
||||||
ppins = printer.lookup_object('pins')
|
ppins = printer.lookup_object('pins')
|
||||||
self.mcu_endstop = ppins.setup_pin('endstop', config.get('endstop_pin'))
|
self.mcu_endstop = ppins.setup_pin('endstop', config.get('endstop_pin'))
|
||||||
self.mcu_endstop.add_stepper(self.mcu_stepper)
|
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')
|
self.position_endstop = config.getfloat('position_endstop')
|
||||||
else:
|
else:
|
||||||
self.position_endstop = config.getfloat(
|
self.position_endstop = config.getfloat(
|
||||||
'position_endstop', default_position)
|
'position_endstop', default_position_endstop)
|
||||||
# Axis range
|
# Axis range
|
||||||
self.position_min = config.getfloat('position_min', 0.)
|
if need_position_minmax:
|
||||||
self.position_max = config.getfloat(
|
self.position_min = config.getfloat('position_min', 0.)
|
||||||
'position_max', 0., above=self.position_min)
|
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
|
# Homing mechanics
|
||||||
self.homing_speed = config.getfloat('homing_speed', 5.0, above=0.)
|
self.homing_speed = config.getfloat('homing_speed', 5.0, above=0.)
|
||||||
self.homing_retract_dist = config.getfloat(
|
self.homing_retract_dist = config.getfloat(
|
||||||
|
|
Loading…
Reference in New Issue