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>
This commit is contained in:
Kevin O'Connor 2020-09-09 13:16:02 -04:00
parent 9197975625
commit 13ee6032ae
1 changed files with 7 additions and 4 deletions

View File

@ -213,9 +213,12 @@ 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),
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)