aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-10-27 12:22:23 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-10-27 12:22:23 -0400
commit4f89251f03f0ae7fdf23ce50e4105ac7ec86d3a2 (patch)
tree3b926122fb14b75a3a287c304040e957fa017aec
parentc3f916c60e4380bee2ed3a2bff80842dcae42f6c (diff)
downloadkutter-4f89251f03f0ae7fdf23ce50e4105ac7ec86d3a2.tar.gz
kutter-4f89251f03f0ae7fdf23ce50e4105ac7ec86d3a2.tar.xz
kutter-4f89251f03f0ae7fdf23ce50e4105ac7ec86d3a2.zip
sx1509: Raise an error if a pin max_duration is not zero
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/sx1509.py9
1 files changed, 8 insertions, 1 deletions
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" % (