mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-08 23:46:25 -06:00
mcu: Allow both shutdown and startup values to be set for output pins
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
e6e0a21b06
commit
68d03e4a3e
3 changed files with 27 additions and 20 deletions
|
@ -137,7 +137,7 @@ class pca9685_pwm:
|
|||
self._max_duration = 2.
|
||||
self._oid = None
|
||||
self._invert = pin_params['invert']
|
||||
self._shutdown_value = float(self._invert)
|
||||
self._start_value = self._shutdown_value = float(self._invert)
|
||||
self._last_clock = 0
|
||||
self._pwm_max = 0.
|
||||
self._cmd_queue = self._mcu.alloc_command_queue()
|
||||
|
@ -156,10 +156,12 @@ class pca9685_pwm:
|
|||
if self._invert:
|
||||
value = 1. - value
|
||||
self._static_value = max(0., min(1., value))
|
||||
def setup_shutdown_value(self, value):
|
||||
def setup_start_value(self, start_value, shutdown_value):
|
||||
if self._invert:
|
||||
value = 1. - value
|
||||
self._shutdown_value = max(0., min(1., value))
|
||||
start_value = 1. - start_value
|
||||
shutdown_value = 1. - shutdown_value
|
||||
self._start_value = max(0., min(1., start_value))
|
||||
self._shutdown_value = max(0., min(1., shutdown_value))
|
||||
if self._shutdown_value:
|
||||
self._replicape.note_enable_on_shutdown()
|
||||
def build_config(self):
|
||||
|
@ -178,7 +180,7 @@ class pca9685_pwm:
|
|||
"config_pca9685 oid=%d bus=%d addr=%d channel=%d cycle_ticks=%d"
|
||||
" value=%d default_value=%d max_duration=%d" % (
|
||||
self._oid, self._bus, self._address, self._channel, cycle_ticks,
|
||||
self._invert * self._pwm_max,
|
||||
self._start_value * self._pwm_max,
|
||||
self._shutdown_value * self._pwm_max,
|
||||
self._mcu.seconds_to_clock(self._max_duration)))
|
||||
self._set_cmd = self._mcu.lookup_command(
|
||||
|
@ -269,7 +271,7 @@ class Replicape:
|
|||
REPLICAPE_SHIFT_REGISTER_BUS, REPLICAPE_SHIFT_REGISTER_DEVICE,
|
||||
"".join(["%02x" % (x,) for x in shift_registers])))
|
||||
def note_enable_on_shutdown(self):
|
||||
self.mcu_enable.setup_shutdown_value(1)
|
||||
self.mcu_enable.setup_start_value(0, 1)
|
||||
def note_enable(self, print_time, channel, is_enable):
|
||||
if is_enable:
|
||||
is_off = not self.enabled_channels
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue