Skip to content

Don't invert the polarity of the GPIO pins by default #21

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

Merged
merged 4 commits into from
Feb 12, 2020
Merged
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
17 changes: 12 additions & 5 deletions adafruit_mcp230xx/mcp23008.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@
# pylint: disable=bad-whitespace
_MCP23008_ADDRESS = const(0x20)
_MCP23008_IODIR = const(0x00)
_MCP23008_IPOL = const(0x01)
_MCP23008_GPINTEN = const(0x02)
_MCP23008_DEFVAL = const(0x03)
_MCP23008_INTCON = const(0x04)
_MCP23008_IOCON = const(0x05)
_MCP23008_GPPU = const(0x06)
_MCP23008_INTF = const(0x07)
_MCP23008_INTCAP = const(0x08)
_MCP23008_GPIO = const(0x09)


Expand All @@ -50,11 +57,11 @@ class MCP23008(MCP230XX):

def __init__(self, i2c, address=_MCP23008_ADDRESS):
super().__init__(i2c, address)
# Reset device state to all pins as inputs (safest option).
with self._device as device:
# Write to MCP23008_IODIR register 0xFF followed by 9 zeros
# for defaults of other registers.
device.write('\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00')

# Reset to all inputs with no pull-ups and no inverted polarity.
self.iodir = 0xFF
self.gppu = 0x00
self._write_u8(_MCP23008_IPOL, 0x00)

@property
def gpio(self):
Expand Down