stepper_enable: Add new extras module for stepper enable line tracking

Move the M18/M84 command handling from gcode.py to new stepper_enable
module.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-11-10 11:55:53 -05:00
parent 064804b688
commit f50e054bd0
3 changed files with 23 additions and 5 deletions

View File

@ -0,0 +1,20 @@
# Support for enable pins on stepper motor drivers
#
# Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
class StepperEnable:
def __init__(self, config):
self.printer = config.get_printer()
# Register M18/M84 commands
gcode = self.printer.lookup_object('gcode')
gcode.register_command("M18", self.cmd_M18)
gcode.register_command("M84", self.cmd_M18)
def cmd_M18(self, params):
# Turn off motors
toolhead = self.printer.lookup_object('toolhead')
toolhead.motor_off()
def load_config(config):
return StepperEnable(config)

View File

@ -475,7 +475,7 @@ class GCodeParser:
key_param, key)) key_param, key))
values[key_param](params) values[key_param](params)
all_handlers = [ all_handlers = [
'G1', 'G4', 'G28', 'M18', 'M400', 'G1', 'G4', 'G28', 'M400',
'G20', 'M82', 'M83', 'G90', 'G91', 'G92', 'M114', 'M220', 'M221', 'G20', 'M82', 'M83', 'G90', 'G91', 'G92', 'M114', 'M220', 'M221',
'SET_GCODE_OFFSET', 'M206', 'SAVE_GCODE_STATE', 'RESTORE_GCODE_STATE', 'SET_GCODE_OFFSET', 'M206', 'SAVE_GCODE_STATE', 'RESTORE_GCODE_STATE',
'M105', 'M104', 'M109', 'M140', 'M190', 'M106', 'M107', 'M105', 'M104', 'M109', 'M140', 'M190', 'M106', 'M107',
@ -536,10 +536,6 @@ class GCodeParser:
for axis in homing_state.get_axes(): for axis in homing_state.get_axes():
self.base_position[axis] = self.homing_position[axis] self.base_position[axis] = self.homing_position[axis]
self.reset_last_position() self.reset_last_position()
cmd_M18_aliases = ["M84"]
def cmd_M18(self, params):
# Turn off motors
self.toolhead.motor_off()
def cmd_M400(self, params): def cmd_M400(self, params):
# Wait for current moves to finish # Wait for current moves to finish
self.toolhead.wait_moves() self.toolhead.wait_moves()

View File

@ -70,6 +70,8 @@ class PrinterStepper:
mcu_stepper.setup_dir_pin(dir_pin_params) mcu_stepper.setup_dir_pin(dir_pin_params)
step_dist = config.getfloat('step_distance', above=0.) step_dist = config.getfloat('step_distance', above=0.)
mcu_stepper.setup_step_distance(step_dist) mcu_stepper.setup_step_distance(step_dist)
# Enable pin handling
stepper_enable = printer.try_load_module(config, 'stepper_enable')
mcu_stepper.add_active_callback(self._stepper_active) mcu_stepper.add_active_callback(self._stepper_active)
self.enable = lookup_enable_pin(ppins, config.get('enable_pin', None)) self.enable = lookup_enable_pin(ppins, config.get('enable_pin', None))
# Register STEPPER_BUZZ command # Register STEPPER_BUZZ command