Open kattni opened 3 years ago
The checks being done in adafruit_seesaw.digitalio.py
are based on the core digitalio
library defines. But the Seesaw
class in adafruit_seesaw.seesaw.py
also defines its own set. Mixing these (first example above) is what is leading to this issue.
adafruit_seesaw.Seesaw.INPUT_PULLUP != digitalio.Direction.INPUT_PULLUP
Not sure what the proper solution is. Open for discussion. :)
Should the incorrect code be detected as an error, like
diff --git a/adafruit_seesaw/digitalio.py b/adafruit_seesaw/digitalio.py
index ca9a1f4..4d84be7 100644
--- a/adafruit_seesaw/digitalio.py
+++ b/adafruit_seesaw/digitalio.py
@@ -49,8 +49,10 @@ class DigitalIO:
self._seesaw.pin_mode(self._pin, self._seesaw.INPUT_PULLDOWN)
elif pull == digitalio.Pull.UP:
self._seesaw.pin_mode(self._pin, self._seesaw.INPUT_PULLUP)
- else:
+ elif pull is None:
self._seesaw.pin_mode(self._pin, self._seesaw.INPUT)
+ else:
+ raise ValueError("Out of range")
self._pull = pull
@property
That'd help with visibility, since it would gripe instead of silently accepting and doing something unexpected.
I guess this could be considered a bug in user code:
button.switch_to_input(pull=ss.INPUT_PULLUP)
since ss.INPUT_PULLUP
is a mode
, not a pull
.
The following code should work.
However, it does not. The pin is left floating. The following code, does work.
Presumably the first example is supposed to work like the second example, but it does not. I have no suggestions on where to start with fixing this.