mirror of
https://github.com/Klipper3d/klipper.git
synced 2026-03-06 01:54:42 -07:00
pwm_tool: fix missing updates
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:
parent
0624cce4b3
commit
7a44726492
1 changed files with 9 additions and 4 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue