Skip to content

Commit 31b5825

Browse files
authored
Merge pull request #21 from foozmeat/master
Don't invert the polarity of the GPIO pins by default
2 parents d244de2 + ecb63f1 commit 31b5825

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

adafruit_mcp230xx/mcp23008.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@
3939
# pylint: disable=bad-whitespace
4040
_MCP23008_ADDRESS = const(0x20)
4141
_MCP23008_IODIR = const(0x00)
42+
_MCP23008_IPOL = const(0x01)
43+
_MCP23008_GPINTEN = const(0x02)
44+
_MCP23008_DEFVAL = const(0x03)
45+
_MCP23008_INTCON = const(0x04)
46+
_MCP23008_IOCON = const(0x05)
4247
_MCP23008_GPPU = const(0x06)
48+
_MCP23008_INTF = const(0x07)
49+
_MCP23008_INTCAP = const(0x08)
4350
_MCP23008_GPIO = const(0x09)
4451

4552

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

5158
def __init__(self, i2c, address=_MCP23008_ADDRESS):
5259
super().__init__(i2c, address)
53-
# Reset device state to all pins as inputs (safest option).
54-
with self._device as device:
55-
# Write to MCP23008_IODIR register 0xFF followed by 9 zeros
56-
# for defaults of other registers.
57-
device.write('\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00')
60+
61+
# Reset to all inputs with no pull-ups and no inverted polarity.
62+
self.iodir = 0xFF
63+
self.gppu = 0x00
64+
self._write_u8(_MCP23008_IPOL, 0x00)
5865

5966
@property
6067
def gpio(self):

0 commit comments

Comments
 (0)