mirror of
https://github.com/andreili/klipper.git
synced 2025-09-15 09:51:12 +02:00
stepper_enable: Improve timing of manual stepper enable/disable commands
Invoke flush_step_generation() prior to checking motor enable state as this is the best way to ensure all stepper active callbacks have been invoked (which could change the enable line state). Also, there is no longer a reason to add additional toolhead dwells when enabling a stepper motor. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
1f14e950e7
commit
5056e1031c
@ -49,11 +49,9 @@ class ManualStepper:
|
||||
else:
|
||||
self.next_cmd_time = print_time
|
||||
def do_enable(self, enable):
|
||||
self.sync_print_time()
|
||||
stepper_names = [s.get_name() for s in self.steppers]
|
||||
stepper_enable = self.printer.lookup_object('stepper_enable')
|
||||
stepper_enable.set_motors_enable(stepper_names, enable)
|
||||
self.sync_print_time()
|
||||
def do_set_position(self, setpos):
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
toolhead.flush_step_generation()
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Support for enable pins on stepper motor drivers
|
||||
#
|
||||
# Copyright (C) 2019-2021 Kevin O'Connor <kevin@koconnor.net>
|
||||
# Copyright (C) 2019-2025 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import logging
|
||||
@ -90,18 +90,26 @@ class PrinterStepperEnable:
|
||||
self.enable_lines[name] = EnableTracking(mcu_stepper, enable)
|
||||
def set_motors_enable(self, stepper_names, enable):
|
||||
toolhead = self.printer.lookup_object('toolhead')
|
||||
toolhead.dwell(DISABLE_STALL_TIME)
|
||||
print_time = toolhead.get_last_move_time()
|
||||
# Flush steps to ensure all auto enable callbacks invoked
|
||||
toolhead.flush_step_generation()
|
||||
print_time = None
|
||||
did_change = False
|
||||
for stepper_name in stepper_names:
|
||||
el = self.enable_lines[stepper_name]
|
||||
was_enabled = el.is_motor_enabled()
|
||||
if el.is_motor_enabled() == enable:
|
||||
continue
|
||||
if print_time is None:
|
||||
# Dwell for sufficient delay from any previous auto enable
|
||||
if not enable:
|
||||
toolhead.dwell(DISABLE_STALL_TIME)
|
||||
print_time = toolhead.get_last_move_time()
|
||||
if enable:
|
||||
el.motor_enable(print_time)
|
||||
else:
|
||||
el.motor_disable(print_time)
|
||||
if was_enabled != el.is_motor_enabled():
|
||||
did_change = True
|
||||
# Dwell to ensure sufficient delay prior to a future auto enable
|
||||
if did_change and not enable:
|
||||
toolhead.dwell(DISABLE_STALL_TIME)
|
||||
return did_change
|
||||
def motor_off(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user