gpiocmds: Specify soft pwm duration in clock ticks
Improve the precision of soft pwm pulses by allowing the host to directly specify the clock duration of the pulse. This improvement in precision may be noticeable when controller servos (and bltouch). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -341,7 +341,7 @@ class MCU_pwm:
|
||||
or self._shutdown_value not in [0., 1.]):
|
||||
raise pins.error(
|
||||
"start and shutdown values must be 0.0 or 1.0 on soft pwm")
|
||||
self._pwm_max = self._mcu.get_constant_float("SOFT_PWM_MAX")
|
||||
self._pwm_max = float(cycle_ticks)
|
||||
if self._is_static:
|
||||
self._mcu.add_config_cmd("set_digital_out pin=%s value=%d" % (
|
||||
self._pin, self._start_value >= 0.5))
|
||||
@@ -354,7 +354,8 @@ class MCU_pwm:
|
||||
self._start_value >= 0.5, self._shutdown_value >= 0.5,
|
||||
self._mcu.seconds_to_clock(self._max_duration)))
|
||||
self._set_cmd = self._mcu.lookup_command(
|
||||
"schedule_soft_pwm_out oid=%c clock=%u value=%hu", cq=cmd_queue)
|
||||
"schedule_soft_pwm_out oid=%c clock=%u on_ticks=%u",
|
||||
cq=cmd_queue)
|
||||
def set_pwm(self, print_time, value):
|
||||
clock = self._mcu.print_time_to_clock(print_time)
|
||||
if self._invert:
|
||||
|
||||
Reference in New Issue
Block a user