stepper: Simplify helper module registration of stepper motors
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
c632b377ca
commit
f0dbeb0493
|
@ -49,9 +49,8 @@ class ForceMove:
|
|||
gcode.register_command('SET_KINEMATIC_POSITION',
|
||||
self.cmd_SET_KINEMATIC_POSITION,
|
||||
desc=self.cmd_SET_KINEMATIC_POSITION_help)
|
||||
def register_stepper(self, stepper):
|
||||
name = stepper.get_name()
|
||||
self.steppers[name] = stepper
|
||||
def register_stepper(self, config, mcu_stepper):
|
||||
self.steppers[mcu_stepper.get_name()] = mcu_stepper
|
||||
def lookup_stepper(self, name):
|
||||
if name not in self.steppers:
|
||||
raise self.printer.config_error("Unknown stepper %s" % (name,))
|
||||
|
|
|
@ -84,10 +84,10 @@ class PrinterStepperEnable:
|
|||
gcode.register_command("SET_STEPPER_ENABLE",
|
||||
self.cmd_SET_STEPPER_ENABLE,
|
||||
desc=self.cmd_SET_STEPPER_ENABLE_help)
|
||||
def register_stepper(self, stepper, pin):
|
||||
name = stepper.get_name()
|
||||
enable = setup_enable_pin(self.printer, pin)
|
||||
self.enable_lines[name] = EnableTracking(stepper, enable)
|
||||
def register_stepper(self, config, mcu_stepper):
|
||||
name = mcu_stepper.get_name()
|
||||
enable = setup_enable_pin(self.printer, config.get('enable_pin', None))
|
||||
self.enable_lines[name] = EnableTracking(mcu_stepper, enable)
|
||||
def motor_off(self):
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
toolhead.dwell(DISABLE_STALL_TIME)
|
||||
|
|
|
@ -197,12 +197,10 @@ def PrinterStepper(config, units_in_radians=False):
|
|||
step_dist = parse_step_distance(config, units_in_radians, True)
|
||||
mcu_stepper = MCU_stepper(name, step_pin_params, dir_pin_params, step_dist,
|
||||
units_in_radians)
|
||||
# Support for stepper enable pin handling
|
||||
stepper_enable = printer.load_object(config, 'stepper_enable')
|
||||
stepper_enable.register_stepper(mcu_stepper, config.get('enable_pin', None))
|
||||
# Register STEPPER_BUZZ command
|
||||
force_move = printer.load_object(config, 'force_move')
|
||||
force_move.register_stepper(mcu_stepper)
|
||||
# Register with helper modules
|
||||
for mname in ['stepper_enable', 'force_move']:
|
||||
m = printer.load_object(config, mname)
|
||||
m.register_stepper(config, mcu_stepper)
|
||||
return mcu_stepper
|
||||
|
||||
# Parse stepper gear_ratio config parameter
|
||||
|
|
Loading…
Reference in New Issue