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):
|
def set_digital(self, print_time, value):
|
||||||
for mcu_pin in self.mcu_pins:
|
for mcu_pin in self.mcu_pins:
|
||||||
mcu_pin.set_digital(print_time, value)
|
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:
|
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):
|
def load_config_prefix(config):
|
||||||
return PrinterMultiPin(config)
|
return PrinterMultiPin(config)
|
||||||
|
|
|
@ -67,7 +67,7 @@ class pca9685_pwm:
|
||||||
cmd_queue = self._mcu.alloc_command_queue()
|
cmd_queue = self._mcu.alloc_command_queue()
|
||||||
self._set_cmd = self._mcu.lookup_command(
|
self._set_cmd = self._mcu.lookup_command(
|
||||||
"queue_pca9685_out oid=%c clock=%u value=%hu", cq=cmd_queue)
|
"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)
|
clock = self._mcu.print_time_to_clock(print_time)
|
||||||
if self._invert:
|
if self._invert:
|
||||||
value = 1. - value
|
value = 1. - value
|
||||||
|
|
|
@ -183,7 +183,7 @@ class SX1509_pwm(object):
|
||||||
shutdown_value = 1. - shutdown_value
|
shutdown_value = 1. - shutdown_value
|
||||||
self._start_value = max(0., min(1., start_value))
|
self._start_value = max(0., min(1., start_value))
|
||||||
self._shutdown_value = max(0., min(1., shutdown_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)
|
self._sx1509.set_register(self._i_on_reg, ~int(255 * value)
|
||||||
if not self._invert
|
if not self._invert
|
||||||
else int(255 * value) & 0xFF)
|
else int(255 * value) & 0xFF)
|
||||||
|
|
|
@ -381,9 +381,9 @@ class MCU_pwm:
|
||||||
self._pin = pin_params['pin']
|
self._pin = pin_params['pin']
|
||||||
self._invert = pin_params['invert']
|
self._invert = pin_params['invert']
|
||||||
self._start_value = self._shutdown_value = float(self._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._pwm_max = 0.
|
||||||
self._set_cmd = self._set_cycle_ticks = None
|
self._set_cmd = None
|
||||||
def get_mcu(self):
|
def get_mcu(self):
|
||||||
return self._mcu
|
return self._mcu
|
||||||
def setup_max_duration(self, max_duration):
|
def setup_max_duration(self, max_duration):
|
||||||
|
@ -441,40 +441,21 @@ class MCU_pwm:
|
||||||
self._mcu.add_config_cmd(
|
self._mcu.add_config_cmd(
|
||||||
"set_digital_out_pwm_cycle oid=%d cycle_ticks=%d"
|
"set_digital_out_pwm_cycle oid=%d cycle_ticks=%d"
|
||||||
% (self._oid, cycle_ticks))
|
% (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)
|
svalue = int(self._start_value * cycle_ticks + 0.5)
|
||||||
self._mcu.add_config_cmd(
|
self._mcu.add_config_cmd(
|
||||||
"queue_digital_out oid=%d clock=%d on_ticks=%d"
|
"queue_digital_out oid=%d clock=%d on_ticks=%d"
|
||||||
% (self._oid, self._last_clock, svalue), is_init=True)
|
% (self._oid, self._last_clock, svalue), is_init=True)
|
||||||
self._set_cmd = self._mcu.lookup_command(
|
self._set_cmd = self._mcu.lookup_command(
|
||||||
"queue_digital_out oid=%c clock=%u on_ticks=%u", cq=cmd_queue)
|
"queue_digital_out oid=%c clock=%u on_ticks=%u", cq=cmd_queue)
|
||||||
self._set_cycle_ticks = self._mcu.lookup_command(
|
def set_pwm(self, print_time, value):
|
||||||
"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
|
|
||||||
if self._invert:
|
if self._invert:
|
||||||
value = 1. - value
|
value = 1. - value
|
||||||
if self._hardware_pwm:
|
v = int(max(0., min(1., value)) * self._pwm_max + 0.5)
|
||||||
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],
|
self._set_cmd.send([self._oid, clock, v],
|
||||||
minclock=minclock, reqclock=clock)
|
minclock=self._last_clock, reqclock=clock)
|
||||||
return
|
self._last_clock = clock
|
||||||
# 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)
|
|
||||||
|
|
||||||
class MCU_adc:
|
class MCU_adc:
|
||||||
def __init__(self, mcu, pin_params):
|
def __init__(self, mcu, pin_params):
|
||||||
|
|
Loading…
Reference in New Issue