diff --git a/klippy/extras/pwm_tool.py b/klippy/extras/pwm_tool.py index a069dd2d8..954bd2093 100644 --- a/klippy/extras/pwm_tool.py +++ b/klippy/extras/pwm_tool.py @@ -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):