From 126275d1f4921b60d249c352169fe7ffd860b4ac Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 6 Aug 2025 21:20:55 -0400 Subject: [PATCH] toolhead: Default note_mcu_movequeue_activity() to set step_gen_time Change note_mcu_movequeue_activity() to default to setting the step_gen_time (instead of the previous default to not set it). Most users of the mcu "move queue" will be for stepper activity. There is also little harm in incrementing the tracking of the last possible step generation time, but accidentally generating a step without incrementing the tracking can lead to very hard to debug failures. The two cases (output_pin.py and pwm_tool.py) where note_mcu_movequeue_activity() is called and definitely not related to step generation can explicitly pass 'is_step_gen=False'. Signed-off-by: Kevin O'Connor --- klippy/extras/output_pin.py | 5 +++-- klippy/extras/pwm_tool.py | 3 ++- klippy/toolhead.py | 10 ++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/klippy/extras/output_pin.py b/klippy/extras/output_pin.py index bde7ea69..05266382 100644 --- a/klippy/extras/output_pin.py +++ b/klippy/extras/output_pin.py @@ -50,10 +50,11 @@ class GCodeRequestQueue: del rqueue[:pos+1] self.next_min_flush_time = next_time + max(min_wait, min_sched_time) # Ensure following queue items are flushed - self.toolhead.note_mcu_movequeue_activity(self.next_min_flush_time) + self.toolhead.note_mcu_movequeue_activity(self.next_min_flush_time, + is_step_gen=False) def _queue_request(self, print_time, value): self.rqueue.append((print_time, value)) - self.toolhead.note_mcu_movequeue_activity(print_time) + self.toolhead.note_mcu_movequeue_activity(print_time, is_step_gen=False) def queue_gcode_request(self, value): self.toolhead.register_lookahead_callback( (lambda pt: self._queue_request(pt, value))) diff --git a/klippy/extras/pwm_tool.py b/klippy/extras/pwm_tool.py index 46873203..53e101ae 100644 --- a/klippy/extras/pwm_tool.py +++ b/klippy/extras/pwm_tool.py @@ -115,7 +115,8 @@ class MCU_queued_pwm: # Continue flushing to resend time wakeclock += self._duration_ticks wake_print_time = self._mcu.clock_to_print_time(wakeclock) - self._toolhead.note_mcu_movequeue_activity(wake_print_time) + self._toolhead.note_mcu_movequeue_activity(wake_print_time, + is_step_gen=False) def set_pwm(self, print_time, value): clock = self._mcu.print_time_to_clock(print_time) if self._invert: diff --git a/klippy/toolhead.py b/klippy/toolhead.py index c78b215b..bddba4c7 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -342,8 +342,7 @@ class ToolHead: for cb in move.timing_callbacks: cb(next_move_time) # Generate steps for moves - self.note_mcu_movequeue_activity(next_move_time + self.kin_flush_delay, - set_step_gen_time=True) + self.note_mcu_movequeue_activity(next_move_time + self.kin_flush_delay) self._advance_move_time(next_move_time) def _flush_lookahead(self): # Transit from "NeedPrime"/"Priming"/"Drip"/main state to "NeedPrime" @@ -539,8 +538,7 @@ class ToolHead: drip_completion.wait(curtime + wait_time) continue npt = min(self.print_time + DRIP_SEGMENT_TIME, next_print_time) - self.note_mcu_movequeue_activity(npt + self.kin_flush_delay, - set_step_gen_time=True) + self.note_mcu_movequeue_activity(npt + self.kin_flush_delay) for stepper in addstepper: stepper.generate_steps(npt) self._advance_move_time(npt) @@ -638,9 +636,9 @@ class ToolHead: callback(self.get_last_move_time()) return last_move.timing_callbacks.append(callback) - def note_mcu_movequeue_activity(self, mq_time, set_step_gen_time=False): + def note_mcu_movequeue_activity(self, mq_time, is_step_gen=True): self.need_flush_time = max(self.need_flush_time, mq_time) - if set_step_gen_time: + if is_step_gen: self.step_gen_time = max(self.step_gen_time, mq_time) if self.do_kick_flush_timer: self.do_kick_flush_timer = False