Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digitalio: enable PULL_DOWN mode #45

Merged
merged 3 commits into from
Jan 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions adafruit_seesaw/digitalio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions adafruit_seesaw/seesaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down