From 8f920354b0e80152544c2759fa59e8ed00b575f8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 2 Jan 2020 10:23:44 -0600 Subject: [PATCH 1/3] digitalio: Enable Pull.DOWN mode --- adafruit_seesaw/digitalio.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_seesaw/digitalio.py b/adafruit_seesaw/digitalio.py index 764c259..f9c9f63 100644 --- a/adafruit_seesaw/digitalio.py +++ b/adafruit_seesaw/digitalio.py @@ -62,8 +62,8 @@ def switch_to_output(self, value=False, drive_mode=digitalio.DriveMode.PUSH_PULL def switch_to_input(self, pull=None): """Switch the pin to input mode""" if pull == digitalio.Pull.DOWN: - raise ValueError("Pull Down currently not supported") - if pull == digitalio.Pull.UP: + 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: self._seesaw.pin_mode(self._pin, self._seesaw.INPUT) @@ -117,8 +117,8 @@ def pull(self, mode): if self._direction == digitalio.Direction.OUTPUT: raise AttributeError("cannot set pull on an output pin") if mode == digitalio.Pull.DOWN: - raise ValueError("Pull Down currently not supported") - if mode == digitalio.Pull.UP: + self._seesaw.pin_mode(self._pin, self._seesaw.INPUT_PULLDOWN) + elif mode == digitalio.Pull.UP: self._seesaw.pin_mode(self._pin, self._seesaw.INPUT_PULLUP) elif mode is None: self._seesaw.pin_mode(self._pin, self._seesaw.INPUT) From 20fb91a810d8044db1d0591efe7149fcbe9facd5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 2 Jan 2020 10:47:55 -0600 Subject: [PATCH 2/3] seesaw: Clear pull-ups when setting mode to INPUT .. pull-ups are enabled with INPUT_PULLUP, INPUT_PULLDOWN and would otherwise never be disabled --- adafruit_seesaw/seesaw.py | 1 + 1 file changed, 1 insertion(+) diff --git a/adafruit_seesaw/seesaw.py b/adafruit_seesaw/seesaw.py index 5824a7d..ff3bce3 100644 --- a/adafruit_seesaw/seesaw.py +++ b/adafruit_seesaw/seesaw.py @@ -277,6 +277,7 @@ def _pin_mode_bulk_x(self, capacity, offset, pins, mode): self.write(_GPIO_BASE, _GPIO_DIRSET_BULK, cmd) elif mode == self.INPUT: self.write(_GPIO_BASE, _GPIO_DIRCLR_BULK, cmd) + self.write(_GPIO_BASE, _GPIO_PULLENCLR, cmd) elif mode == self.INPUT_PULLUP: self.write(_GPIO_BASE, _GPIO_DIRCLR_BULK, cmd) From 08c0f79902de5738ddfed782472ab451eacc8c9c Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 2 Jan 2020 10:48:34 -0600 Subject: [PATCH 3/3] digitalio: Initialize direction to INPUT None is an invalid direction --- adafruit_seesaw/digitalio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_seesaw/digitalio.py b/adafruit_seesaw/digitalio.py index f9c9f63..89cd64d 100644 --- a/adafruit_seesaw/digitalio.py +++ b/adafruit_seesaw/digitalio.py @@ -45,7 +45,7 @@ def __init__(self, seesaw, pin): self._seesaw = seesaw self._pin = pin self._drive_mode = digitalio.DriveMode.PUSH_PULL - self._direction = False + self._direction = digitalio.Direction.INPUT self._pull = None self._value = False