pwm_tool: fix missing updates
Some checks failed
Build test / build (push) Has been cancelled
klipper3d deploy / deploy (push) Has been cancelled

Generate intermediate updates if a set_pwm() call schedules an update
far in the future.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Timofey Titovets 2026-03-01 16:23:55 +01:00 committed by KevinOConnor
parent 0624cce4b3
commit 7a44726492

View file

@ -117,18 +117,23 @@ class MCU_queued_pwm:
wake_print_time = self._mcu.clock_to_print_time(wakeclock)
self._motion_queuing.note_mcu_movequeue_activity(wake_print_time,
is_step_gen=False)
def _gen_intermediate_updates(self, clock):
if self._last_value == self._default_value:
return
while clock >= self._last_clock + self._duration_ticks:
self._send_update(self._last_clock + self._duration_ticks,
self._last_value)
def set_pwm(self, print_time, value):
clock = self._mcu.print_time_to_clock(print_time)
if self._invert:
value = 1. - value
v = int(max(0., min(1., value)) * self._pwm_max + 0.5)
if self._duration_ticks:
self._gen_intermediate_updates(clock - 1)
self._send_update(clock, v)
def _flush_notification(self, must_flush_time, max_step_gen_time):
clock = self._mcu.print_time_to_clock(must_flush_time)
if self._last_value != self._default_value:
while clock >= self._last_clock + self._duration_ticks:
self._send_update(self._last_clock + self._duration_ticks,
self._last_value)
self._gen_intermediate_updates(clock)
class PrinterOutputPin:
def __init__(self, config):