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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2025-08-06 21:20:55 -04:00
parent f8da8099d5
commit 126275d1f4
3 changed files with 9 additions and 9 deletions

View File

@ -50,10 +50,11 @@ class GCodeRequestQueue:
del rqueue[:pos+1] del rqueue[:pos+1]
self.next_min_flush_time = next_time + max(min_wait, min_sched_time) self.next_min_flush_time = next_time + max(min_wait, min_sched_time)
# Ensure following queue items are flushed # 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): def _queue_request(self, print_time, value):
self.rqueue.append((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): def queue_gcode_request(self, value):
self.toolhead.register_lookahead_callback( self.toolhead.register_lookahead_callback(
(lambda pt: self._queue_request(pt, value))) (lambda pt: self._queue_request(pt, value)))

View File

@ -115,7 +115,8 @@ class MCU_queued_pwm:
# Continue flushing to resend time # Continue flushing to resend time
wakeclock += self._duration_ticks wakeclock += self._duration_ticks
wake_print_time = self._mcu.clock_to_print_time(wakeclock) 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): def set_pwm(self, print_time, value):
clock = self._mcu.print_time_to_clock(print_time) clock = self._mcu.print_time_to_clock(print_time)
if self._invert: if self._invert:

View File

@ -342,8 +342,7 @@ class ToolHead:
for cb in move.timing_callbacks: for cb in move.timing_callbacks:
cb(next_move_time) cb(next_move_time)
# Generate steps for moves # Generate steps for moves
self.note_mcu_movequeue_activity(next_move_time + self.kin_flush_delay, self.note_mcu_movequeue_activity(next_move_time + self.kin_flush_delay)
set_step_gen_time=True)
self._advance_move_time(next_move_time) self._advance_move_time(next_move_time)
def _flush_lookahead(self): def _flush_lookahead(self):
# Transit from "NeedPrime"/"Priming"/"Drip"/main state to "NeedPrime" # Transit from "NeedPrime"/"Priming"/"Drip"/main state to "NeedPrime"
@ -539,8 +538,7 @@ class ToolHead:
drip_completion.wait(curtime + wait_time) drip_completion.wait(curtime + wait_time)
continue continue
npt = min(self.print_time + DRIP_SEGMENT_TIME, next_print_time) npt = min(self.print_time + DRIP_SEGMENT_TIME, next_print_time)
self.note_mcu_movequeue_activity(npt + self.kin_flush_delay, self.note_mcu_movequeue_activity(npt + self.kin_flush_delay)
set_step_gen_time=True)
for stepper in addstepper: for stepper in addstepper:
stepper.generate_steps(npt) stepper.generate_steps(npt)
self._advance_move_time(npt) self._advance_move_time(npt)
@ -638,9 +636,9 @@ class ToolHead:
callback(self.get_last_move_time()) callback(self.get_last_move_time())
return return
last_move.timing_callbacks.append(callback) 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) 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) self.step_gen_time = max(self.step_gen_time, mq_time)
if self.do_kick_flush_timer: if self.do_kick_flush_timer:
self.do_kick_flush_timer = False self.do_kick_flush_timer = False