Skip to content

Commit a691635

Browse files
authored
Merge pull request #37 from adafruit/reset-keyword
Added reset keyword
2 parents 34b9c1d + 63de1b8 commit a691635

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

adafruit_mcp230xx/mcp23008.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ class MCP23008(MCP230XX):
3737
at the specified I2C address.
3838
"""
3939

40-
def __init__(self, i2c, address=_MCP23008_ADDRESS):
40+
def __init__(self, i2c, address=_MCP23008_ADDRESS, reset=True):
4141
super().__init__(i2c, address)
4242

43-
# Reset to all inputs with no pull-ups and no inverted polarity.
44-
self.iodir = 0xFF
45-
self.gppu = 0x00
46-
self._write_u8(_MCP23008_IPOL, 0x00)
43+
if reset:
44+
# Reset to all inputs with no pull-ups and no inverted polarity.
45+
self.iodir = 0xFF
46+
self.gppu = 0x00
47+
self._write_u8(_MCP23008_IPOL, 0x00)
4748

4849
@property
4950
def gpio(self):

adafruit_mcp230xx/mcp23016.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ class MCP23016(MCP230XX):
4545
at the specified I2C address.
4646
"""
4747

48-
def __init__(self, i2c, address=_MCP23016_ADDRESS):
48+
def __init__(self, i2c, address=_MCP23016_ADDRESS, reset=True):
4949
super().__init__(i2c, address)
5050

51-
# Reset to all inputs and no inverted polarity.
52-
self.iodir = 0xFFFF
53-
self._write_u16le(_MCP23016_IPOL0, 0x0000)
51+
if reset:
52+
# Reset to all inputs and no inverted polarity.
53+
self.iodir = 0xFFFF
54+
self._write_u16le(_MCP23016_IPOL0, 0x0000)
5455

5556
@property
5657
def gpio(self):

adafruit_mcp230xx/mcp23017.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ class MCP23017(MCP230XX):
4545
at the specified I2C address.
4646
"""
4747

48-
def __init__(self, i2c, address=_MCP23017_ADDRESS):
48+
def __init__(self, i2c, address=_MCP23017_ADDRESS, reset=True):
4949
super().__init__(i2c, address)
50-
# Reset to all inputs with no pull-ups and no inverted polarity.
51-
self.iodir = 0xFFFF
52-
self.gppu = 0x0000
53-
self.iocon = 0x4 # turn on IRQ Pins as open drain
54-
self._write_u16le(_MCP23017_IPOLA, 0x0000)
50+
if reset:
51+
# Reset to all inputs with no pull-ups and no inverted polarity.
52+
self.iodir = 0xFFFF
53+
self.gppu = 0x0000
54+
self.iocon = 0x4 # turn on IRQ Pins as open drain
55+
self._write_u16le(_MCP23017_IPOLA, 0x0000)
5556

5657
@property
5758
def gpio(self):

0 commit comments

Comments
 (0)