aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-11-12 11:41:41 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-11-12 17:32:18 -0500
commitbfb34e07017248268474281dc6678a8d141458ad (patch)
tree70ea938b8c9686bf3909e4b4a5c1499058af218d /klippy/extras
parentf50e054bd069a0e7ae9455dfa5ddfc6894c4789e (diff)
downloadkutter-bfb34e07017248268474281dc6678a8d141458ad.tar.gz
kutter-bfb34e07017248268474281dc6678a8d141458ad.tar.xz
kutter-bfb34e07017248268474281dc6678a8d141458ad.zip
stepper_enable: Move motor_off() logic to stepper_enable.py
Directly disable all the stepper motors on a global motor_off() from the StepperEnable() class in stepper_enable.py. This simplifies the toolhead and kinematic classes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras')
-rw-r--r--klippy/extras/manual_stepper.py4
-rw-r--r--klippy/extras/stepper_enable.py22
2 files changed, 20 insertions, 6 deletions
diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py
index 73766622..da65a5a4 100644
--- a/klippy/extras/manual_stepper.py
+++ b/klippy/extras/manual_stepper.py
@@ -35,8 +35,6 @@ class ManualStepper:
self.gcode.register_mux_command('MANUAL_STEPPER', "STEPPER",
stepper_name, self.cmd_MANUAL_STEPPER,
desc=self.cmd_MANUAL_STEPPER_help)
- self.printer.register_event_handler(
- "toolhead:motor_off", self.handle_motor_off)
def sync_print_time(self):
toolhead = self.printer.lookup_object('toolhead')
print_time = toolhead.get_last_move_time()
@@ -114,8 +112,6 @@ class ManualStepper:
elif 'MOVE' in params:
movepos = self.gcode.get_float('MOVE', params)
self.do_move(movepos, speed, accel)
- def handle_motor_off(self, print_time):
- self.do_enable(0)
def load_config_prefix(config):
return ManualStepper(config)
diff --git a/klippy/extras/stepper_enable.py b/klippy/extras/stepper_enable.py
index 5d9e6a41..46f93f65 100644
--- a/klippy/extras/stepper_enable.py
+++ b/klippy/extras/stepper_enable.py
@@ -3,18 +3,36 @@
# Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
+import logging
+
+DISABLE_STALL_TIME = 0.100
class StepperEnable:
def __init__(self, config):
self.printer = config.get_printer()
+ self.steppers = {}
+ self.printer.register_event_handler("gcode:request_restart",
+ self._handle_request_restart)
# 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 register_stepper(self, stepper):
+ self.steppers[stepper.get_name()] = stepper
+ def motor_off(self):
+ toolhead = self.printer.lookup_object('toolhead')
+ toolhead.dwell(DISABLE_STALL_TIME)
+ print_time = toolhead.get_last_move_time()
+ for s in self.steppers.values():
+ s.motor_enable(print_time, 0)
+ self.printer.send_event("stepper_enable:motor_off", print_time)
+ toolhead.dwell(DISABLE_STALL_TIME)
+ logging.debug('; Max time of %f', print_time)
+ def _handle_request_restart(self, print_time):
+ self.motor_off()
def cmd_M18(self, params):
# Turn off motors
- toolhead = self.printer.lookup_object('toolhead')
- toolhead.motor_off()
+ self.motor_off()
def load_config(config):
return StepperEnable(config)