From 864c78f24a0dbfe120313ab996c6e4257f644344 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 5 Aug 2025 00:16:13 -0400 Subject: [PATCH] motion_queueing: Add flush_steppersync() Move the mcu.flush_moves() code to motion_queuing.flush_steppersync(). Signed-off-by: Kevin O'Connor --- klippy/extras/motion_queuing.py | 12 ++++++++++++ klippy/mcu.py | 13 ------------- klippy/toolhead.py | 3 +-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/klippy/extras/motion_queuing.py b/klippy/extras/motion_queuing.py index 55a7b929..fdbb5df2 100644 --- a/klippy/extras/motion_queuing.py +++ b/klippy/extras/motion_queuing.py @@ -16,6 +16,7 @@ class PrinterMotionQueuing: self.flush_callbacks = [] ffi_main, ffi_lib = chelper.get_ffi() self.trapq_finalize_moves = ffi_lib.trapq_finalize_moves + self.steppersync_flush = ffi_lib.steppersync_flush def allocate_trapq(self): ffi_main, ffi_lib = chelper.get_ffi() trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free) @@ -52,6 +53,17 @@ class PrinterMotionQueuing: for trapq in self.trapqs: self.trapq_finalize_moves(trapq, trapq_free_time, clear_history_time) + def flush_steppersync(self, print_time, clear_history_time): + for mcu, ss in self.steppersyncs: + clock = mcu.print_time_to_clock(print_time) + if clock < 0: + continue + clear_history_clock = \ + max(0, mcu.print_time_to_clock(clear_history_time)) + ret = self.steppersync_flush(ss, clock, clear_history_clock) + if ret: + raise mcu.error("Internal error in MCU '%s' stepcompress" + % (mcu.get_name(),)) def wipe_trapq(self, trapq): # Expire any remaining movement in the trapq (force to history list) NEVER = 9999999999999999. diff --git a/klippy/mcu.py b/klippy/mcu.py index c8bc9c9b..db02e2a4 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -970,19 +970,6 @@ class MCU: # Move queue tracking def request_move_queue_slot(self): self._reserved_move_slots += 1 - def flush_moves(self, print_time, clear_history_time): - if self._steppersync is None: - return - clock = self.print_time_to_clock(print_time) - if clock < 0: - return - clear_history_clock = \ - max(0, self.print_time_to_clock(clear_history_time)) - ret = self._ffi_lib.steppersync_flush(self._steppersync, clock, - clear_history_clock) - if ret: - raise error("Internal error in MCU '%s' stepcompress" - % (self._name,)) def check_active(self, print_time, eventtime): if self._steppersync is None: return diff --git a/klippy/toolhead.py b/klippy/toolhead.py index bc8c254d..6fd5f2de 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -285,8 +285,7 @@ class ToolHead: free_time = sg_flush_time - self.kin_flush_delay self.motion_queuing.clean_motion_queues(free_time, clear_history_time) # Flush stepcompress and mcu steppersync - for m in self.all_mcus: - m.flush_moves(flush_time, clear_history_time) + self.motion_queuing.flush_steppersync(flush_time, clear_history_time) self.last_flush_time = flush_time def _advance_move_time(self, next_print_time): pt_delay = self.kin_flush_delay + STEPCOMPRESS_FLUSH_TIME