mcu: Remove support for set_pwm() cycle_time parameter
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
fd2feff67d
commit
43a9685c58
|
@ -46,9 +46,9 @@ class PrinterMultiPin:
|
|||
def set_digital(self, print_time, value):
|
||||
for mcu_pin in self.mcu_pins:
|
||||
mcu_pin.set_digital(print_time, value)
|
||||
def set_pwm(self, print_time, value, cycle_time=None):
|
||||
def set_pwm(self, print_time, value):
|
||||
for mcu_pin in self.mcu_pins:
|
||||
mcu_pin.set_pwm(print_time, value, cycle_time)
|
||||
mcu_pin.set_pwm(print_time, value)
|
||||
|
||||
def load_config_prefix(config):
|
||||
return PrinterMultiPin(config)
|
||||
|
|
|
@ -67,7 +67,7 @@ class pca9685_pwm:
|
|||
cmd_queue = self._mcu.alloc_command_queue()
|
||||
self._set_cmd = self._mcu.lookup_command(
|
||||
"queue_pca9685_out oid=%c clock=%u value=%hu", cq=cmd_queue)
|
||||
def set_pwm(self, print_time, value, cycle_time=None):
|
||||
def set_pwm(self, print_time, value):
|
||||
clock = self._mcu.print_time_to_clock(print_time)
|
||||
if self._invert:
|
||||
value = 1. - value
|
||||
|
|
|
@ -183,7 +183,7 @@ class SX1509_pwm(object):
|
|||
shutdown_value = 1. - shutdown_value
|
||||
self._start_value = max(0., min(1., start_value))
|
||||
self._shutdown_value = max(0., min(1., shutdown_value))
|
||||
def set_pwm(self, print_time, value, cycle_time=None):
|
||||
def set_pwm(self, print_time, value):
|
||||
self._sx1509.set_register(self._i_on_reg, ~int(255 * value)
|
||||
if not self._invert
|
||||
else int(255 * value) & 0xFF)
|
||||
|
|
|
@ -381,9 +381,9 @@ class MCU_pwm:
|
|||
self._pin = pin_params['pin']
|
||||
self._invert = pin_params['invert']
|
||||
self._start_value = self._shutdown_value = float(self._invert)
|
||||
self._last_clock = self._last_cycle_ticks = 0
|
||||
self._last_clock = 0
|
||||
self._pwm_max = 0.
|
||||
self._set_cmd = self._set_cycle_ticks = None
|
||||
self._set_cmd = None
|
||||
def get_mcu(self):
|
||||
return self._mcu
|
||||
def setup_max_duration(self, max_duration):
|
||||
|
@ -441,40 +441,21 @@ class MCU_pwm:
|
|||
self._mcu.add_config_cmd(
|
||||
"set_digital_out_pwm_cycle oid=%d cycle_ticks=%d"
|
||||
% (self._oid, cycle_ticks))
|
||||
self._last_cycle_ticks = cycle_ticks
|
||||
self._pwm_max = float(cycle_ticks)
|
||||
svalue = int(self._start_value * cycle_ticks + 0.5)
|
||||
self._mcu.add_config_cmd(
|
||||
"queue_digital_out oid=%d clock=%d on_ticks=%d"
|
||||
% (self._oid, self._last_clock, svalue), is_init=True)
|
||||
self._set_cmd = self._mcu.lookup_command(
|
||||
"queue_digital_out oid=%c clock=%u on_ticks=%u", cq=cmd_queue)
|
||||
self._set_cycle_ticks = self._mcu.lookup_command(
|
||||
"set_digital_out_pwm_cycle oid=%c cycle_ticks=%u", cq=cmd_queue)
|
||||
def set_pwm(self, print_time, value, cycle_time=None):
|
||||
clock = self._mcu.print_time_to_clock(print_time)
|
||||
minclock = self._last_clock
|
||||
self._last_clock = clock
|
||||
def set_pwm(self, print_time, value):
|
||||
if self._invert:
|
||||
value = 1. - value
|
||||
if self._hardware_pwm:
|
||||
v = int(max(0., min(1., value)) * self._pwm_max + 0.5)
|
||||
self._set_cmd.send([self._oid, clock, v],
|
||||
minclock=minclock, reqclock=clock)
|
||||
return
|
||||
# Soft pwm update
|
||||
if cycle_time is None:
|
||||
cycle_time = self._cycle_time
|
||||
cycle_ticks = self._mcu.seconds_to_clock(cycle_time)
|
||||
if cycle_ticks != self._last_cycle_ticks:
|
||||
if cycle_ticks >= 1<<31:
|
||||
raise self._mcu.get_printer().command_error(
|
||||
"PWM cycle time too large")
|
||||
self._set_cycle_ticks.send([self._oid, cycle_ticks],
|
||||
minclock=minclock, reqclock=clock)
|
||||
self._last_cycle_ticks = cycle_ticks
|
||||
on_ticks = int(max(0., min(1., value)) * float(cycle_ticks) + 0.5)
|
||||
self._set_cmd.send([self._oid, clock, on_ticks],
|
||||
minclock=minclock, reqclock=clock)
|
||||
v = int(max(0., min(1., value)) * self._pwm_max + 0.5)
|
||||
clock = self._mcu.print_time_to_clock(print_time)
|
||||
self._set_cmd.send([self._oid, clock, v],
|
||||
minclock=self._last_clock, reqclock=clock)
|
||||
self._last_clock = clock
|
||||
|
||||
class MCU_adc:
|
||||
def __init__(self, mcu, pin_params):
|
||||
|
|
Loading…
Reference in New Issue