motion_queuing: Require explicit notification on a scan window change

Don't try to infer when the step generation scan window may change.
Instead, require the input_shaper and pressure_advance code call
motion_queuing.check_step_generation_scan_windows() any time a
scanning window may change.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2025-09-07 12:18:28 -04:00
parent cde57bdcfd
commit 22db9bb84e
3 changed files with 8 additions and 7 deletions

View file

@ -138,6 +138,7 @@ class InputShaper:
if self.toolhead is None:
# Klipper initialization is not yet completed
return
self.toolhead.flush_step_generation()
ffi_main, ffi_lib = chelper.get_ffi()
kin = self.toolhead.get_kinematics()
for s in kin.get_steppers():
@ -146,8 +147,9 @@ class InputShaper:
is_sk = self._get_input_shaper_stepper_kinematics(s)
if is_sk is None:
continue
self.toolhead.flush_step_generation()
ffi_lib.input_shaper_update_sk(is_sk)
motion_queuing = self.printer.lookup_object("motion_queuing")
motion_queuing.check_step_generation_scan_windows()
def _update_input_shaping(self, error=None):
self.toolhead.flush_step_generation()
ffi_main, ffi_lib = chelper.get_ffi()
@ -164,6 +166,8 @@ class InputShaper:
continue
if not shaper.set_shaper_kinematics(is_sk):
failed_shapers.append(shaper)
motion_queuing = self.printer.lookup_object("motion_queuing")
motion_queuing.check_step_generation_scan_windows()
if failed_shapers:
error = error or self.printer.command_error
raise error("Failed to configure shaper(s) %s with given parameters"

View file

@ -50,7 +50,6 @@ class PrinterMotionQueuing:
if self.mcu.is_fileoutput():
self.can_pause = False
# Kinematic step generation scan window time tracking
self.need_calc_kin_flush_delay = True
self.kin_flush_delay = SDS_CHECK_TIME
# Register handlers
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
@ -129,8 +128,7 @@ class PrinterMotionQueuing:
# Kinematic step generation scan window time tracking
def get_kin_flush_delay(self):
return self.kin_flush_delay
def _calc_kin_flush_delay(self):
self.need_calc_kin_flush_delay = False
def check_step_generation_scan_windows(self):
ffi_main, ffi_lib = chelper.get_ffi()
kin_flush_delay = SDS_CHECK_TIME
for mcu, sc in self.stepcompress:
@ -175,11 +173,8 @@ class PrinterMotionQueuing:
if flush_time >= want_flush_time:
break
def flush_all_steps(self):
self.need_calc_kin_flush_delay = True
self.advance_flush_time(self.need_step_gen_time)
def calc_step_gen_restart(self, est_print_time):
if self.need_calc_kin_flush_delay:
self._calc_kin_flush_delay()
kin_time = max(est_print_time + MIN_KIN_TIME, self.last_step_gen_time)
return kin_time + self.kin_flush_delay
def _flush_handler(self, eventtime):

View file

@ -75,6 +75,8 @@ class ExtruderStepper:
# Need full kinematic flush to change the smooth time
toolhead.flush_step_generation()
espa(self.sk_extruder, 0., pressure_advance, new_smooth_time)
motion_queuing = self.printer.lookup_object('motion_queuing')
motion_queuing.check_step_generation_scan_windows()
else:
toolhead.register_lookahead_callback(
lambda print_time: espa(self.sk_extruder, print_time,