motion_queuing: Track all trapqs and globally flush all trapqs

Add an allocate_trapq() helper function to facilitate the creation of
a low-level C trapq object.  Track all trapq objects and clear history
on them globally when the main motion queues are flushed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-08-04 22:41:15 -04:00
parent 9399e738bc
commit 5cbe7d83e8
5 changed files with 36 additions and 38 deletions

View File

@@ -33,10 +33,10 @@ class ForceMove:
self.printer = config.get_printer()
self.steppers = {}
# Setup iterative solver
self.motion_queuing = self.printer.load_object(config, 'motion_queuing')
self.trapq = self.motion_queuing.allocate_trapq()
self.trapq_append = self.motion_queuing.lookup_trapq_append()
ffi_main, ffi_lib = chelper.get_ffi()
self.trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free)
self.trapq_append = ffi_lib.trapq_append
self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves
self.stepper_kinematics = ffi_main.gc(
ffi_lib.cartesian_stepper_alloc(b'x'), ffi_lib.free)
# Register commands
@@ -90,8 +90,7 @@ class ForceMove:
toolhead.flush_step_generation()
stepper.set_trapq(prev_trapq)
stepper.set_stepper_kinematics(prev_sk)
self.trapq_finalize_moves(self.trapq, print_time + 99999.9,
print_time + 99999.9)
self.motion_queuing.wipe_trapq(self.trapq)
def _lookup_stepper(self, gcmd):
name = gcmd.get('STEPPER')
if name not in self.steppers: