From 4f89251f03f0ae7fdf23ce50e4105ac7ec86d3a2 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 27 Oct 2018 12:22:23 -0400 Subject: [PATCH] sx1509: Raise an error if a pin max_duration is not zero Signed-off-by: Kevin O'Connor --- klippy/extras/sx1509.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/klippy/extras/sx1509.py b/klippy/extras/sx1509.py index 71336ea6..8fb7c507 100644 --- a/klippy/extras/sx1509.py +++ b/klippy/extras/sx1509.py @@ -111,15 +111,20 @@ class SX1509_digital_out(object): self._bitmask = 1 << self._sxpin self._pin = pin_params['pin'] self._invert = pin_params['invert'] + self._mcu.register_config_callback(self._build_config) self._start_value = self._shutdown_value = self._invert self._is_static = False + self._max_duration = 2. self._set_cmd = self._clear_cmd = None # Set direction to output self._sx1509.clear_bits_in_register(REG_DIR, self._bitmask) + def _build_config(self): + if self._max_duration: + raise pins.error("SX1509 pins are not suitable for heaters") def get_mcu(self): return self._mcu def setup_max_duration(self, max_duration): - pass + self._max_duration = max_duration def setup_start_value(self, start_value, shutdown_value, is_static=False): if is_static or shutdown_value: raise pins.error("SX1509 Pins should not be declared static or have a shutdown value") @@ -167,6 +172,8 @@ class SX1509_pwm(object): def _build_config(self): if not self._hardware_pwm: raise pins.error("SX1509_pwm must have hardware_pwm enabled") + if self._max_duration: + raise pins.error("SX1509 pins are not suitable for heaters") # Send initial value self._sx1509.set_register(self._i_on_reg, ~int(255 * self._start_value) & 0xFF) self._mcu.add_config_cmd("i2c_write oid=%d data=%02x%02x" % (