stepper: Implement active callbacks via motion_queuing.register_flush_callback()

Use the existing register_flush_callback() system to implement motor
activity checking.  This simplifies the generate_steps() code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-08-05 14:50:36 -04:00
parent b5e573957c
commit c454e88d9a
4 changed files with 29 additions and 14 deletions

View File

@@ -50,10 +50,15 @@ class PrinterMotionQueuing:
self.steppers.append(stepper)
def register_flush_callback(self, callback):
self.flush_callbacks.append(callback)
def unregister_flush_callback(self, callback):
if callback in self.flush_callbacks:
fcbs = list(self.flush_callbacks)
fcbs.remove(callback)
self.flush_callbacks = fcbs
def flush_motion_queues(self, must_flush_time, max_step_gen_time):
# Invoke flush callbacks (if any)
for cb in self.flush_callbacks:
cb(must_flush_time)
cb(must_flush_time, max_step_gen_time)
# Generate itersolve steps
for stepper in self.steppers:
stepper.generate_steps(max_step_gen_time)