motion_queuing: Add allocate_steppersync() call

Allocate the low-level C steppersync object from the motion_queuing
module.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2025-08-04 23:26:30 -04:00
parent 5cbe7d83e8
commit 128226fe8a
2 changed files with 16 additions and 7 deletions

View File

@ -11,6 +11,7 @@ class PrinterMotionQueuing:
self.printer = config.get_printer()
self.steppers = []
self.trapqs = []
self.steppersyncs = []
ffi_main, ffi_lib = chelper.get_ffi()
self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves
def allocate_trapq(self):
@ -18,6 +19,14 @@ class PrinterMotionQueuing:
trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free)
self.trapqs.append(trapq)
return trapq
def allocate_steppersync(self, mcu, serialqueue, stepqueues, move_count):
ffi_main, ffi_lib = chelper.get_ffi()
ss = ffi_main.gc(
ffi_lib.steppersync_alloc(serialqueue, stepqueues, len(stepqueues),
move_count),
ffi_lib.steppersync_free)
self.steppersyncs.append((mcu, ss))
return ss
def register_stepper(self, config, stepper):
self.steppers.append(stepper)
def flush_motion_queues(self, must_flush_time, max_step_gen_time):

View File

@ -770,13 +770,13 @@ class MCU:
move_count = config_params['move_count']
if move_count < self._reserved_move_slots:
raise error("Too few moves available on MCU '%s'" % (self._name,))
ffi_main, ffi_lib = chelper.get_ffi()
self._steppersync = ffi_main.gc(
ffi_lib.steppersync_alloc(self._serial.get_serialqueue(),
self._stepqueues, len(self._stepqueues),
move_count-self._reserved_move_slots),
ffi_lib.steppersync_free)
ffi_lib.steppersync_set_time(self._steppersync, 0., self._mcu_freq)
ss_move_count = move_count - self._reserved_move_slots
motion_queuing = self._printer.lookup_object('motion_queuing')
self._steppersync = motion_queuing.allocate_steppersync(
self, self._serial.get_serialqueue(),
self._stepqueues, ss_move_count)
self._ffi_lib.steppersync_set_time(self._steppersync,
0., self._mcu_freq)
# Log config information
move_msg = "Configured MCU '%s' (%d moves)" % (self._name, move_count)
logging.info(move_msg)