aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-09-09 13:16:02 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-09-09 13:16:02 -0400
commit13ee6032ae28a4a8dfc1e194c2b5c73e66674df3 (patch)
tree0173eff69c9609cf4012d22b42896a2bc34765c3
parent9197975625daa421334807f6ce6c2b077f615023 (diff)
downloadkutter-13ee6032ae28a4a8dfc1e194c2b5c73e66674df3.tar.gz
kutter-13ee6032ae28a4a8dfc1e194c2b5c73e66674df3.tar.xz
kutter-13ee6032ae28a4a8dfc1e194c2b5c73e66674df3.zip
mcu: Use schedule_pwm_out instead of set_pwm_out on a restart
Some mcu implementations don't like it when the pwm pin is configured twice, so use the normal schedule_pwm_out implementation to update on a restart. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/mcu.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/klippy/mcu.py b/klippy/mcu.py
index 2d26743d..869688f9 100644
--- a/klippy/mcu.py
+++ b/klippy/mcu.py
@@ -213,10 +213,13 @@ class MCU_pwm:
self._start_value * self._pwm_max,
self._shutdown_value * self._pwm_max,
self._mcu.seconds_to_clock(self._max_duration)))
- self._mcu.add_config_cmd(
- "set_pwm_out pin=%s cycle_ticks=%d value=%d"
- % (self._pin, cycle_ticks, self._start_value * self._pwm_max),
- on_restart=True)
+ curtime = self._mcu.get_printer().get_reactor().monotonic()
+ printtime = self._mcu.estimated_print_time(curtime)
+ self._last_clock = self._mcu.print_time_to_clock(printtime + 0.100)
+ svalue = int(self._start_value * self._pwm_max + 0.5)
+ self._mcu.add_config_cmd("schedule_pwm_out oid=%d clock=%d value=%d"
+ % (self._oid, self._last_clock, svalue),
+ on_restart=True)
self._set_cmd = self._mcu.lookup_command(
"schedule_pwm_out oid=%c clock=%u value=%hu", cq=cmd_queue)
return