aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--klippy/extras/stepper_enable.py20
-rw-r--r--klippy/gcode.py6
-rw-r--r--klippy/stepper.py2
3 files changed, 23 insertions, 5 deletions
diff --git a/klippy/extras/stepper_enable.py b/klippy/extras/stepper_enable.py
new file mode 100644
index 00000000..5d9e6a41
--- /dev/null
+++ b/klippy/extras/stepper_enable.py
@@ -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)
diff --git a/klippy/gcode.py b/klippy/gcode.py
index ab5cc012..82e9a303 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -475,7 +475,7 @@ class GCodeParser:
key_param, key))
values[key_param](params)
all_handlers = [
- 'G1', 'G4', 'G28', 'M18', 'M400',
+ 'G1', 'G4', 'G28', 'M400',
'G20', 'M82', 'M83', 'G90', 'G91', 'G92', 'M114', 'M220', 'M221',
'SET_GCODE_OFFSET', 'M206', 'SAVE_GCODE_STATE', 'RESTORE_GCODE_STATE',
'M105', 'M104', 'M109', 'M140', 'M190', 'M106', 'M107',
@@ -536,10 +536,6 @@ class GCodeParser:
for axis in homing_state.get_axes():
self.base_position[axis] = self.homing_position[axis]
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):
# Wait for current moves to finish
self.toolhead.wait_moves()
diff --git a/klippy/stepper.py b/klippy/stepper.py
index 5c72649e..ebeae89b 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -70,6 +70,8 @@ class PrinterStepper:
mcu_stepper.setup_dir_pin(dir_pin_params)
step_dist = config.getfloat('step_distance', above=0.)
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)
self.enable = lookup_enable_pin(ppins, config.get('enable_pin', None))
# Register STEPPER_BUZZ command