Skip to content

Added reset keyword #37

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 1 commit into from
Jan 15, 2021
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
11 changes: 6 additions & 5 deletions adafruit_mcp230xx/mcp23008.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ class MCP23008(MCP230XX):
at the specified I2C address.
"""

def __init__(self, i2c, address=_MCP23008_ADDRESS):
def __init__(self, i2c, address=_MCP23008_ADDRESS, reset=True):
super().__init__(i2c, address)

# Reset to all inputs with no pull-ups and no inverted polarity.
self.iodir = 0xFF
self.gppu = 0x00
self._write_u8(_MCP23008_IPOL, 0x00)
if reset:
# 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
9 changes: 5 additions & 4 deletions adafruit_mcp230xx/mcp23016.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ class MCP23016(MCP230XX):
at the specified I2C address.
"""

def __init__(self, i2c, address=_MCP23016_ADDRESS):
def __init__(self, i2c, address=_MCP23016_ADDRESS, reset=True):
super().__init__(i2c, address)

# Reset to all inputs and no inverted polarity.
self.iodir = 0xFFFF
self._write_u16le(_MCP23016_IPOL0, 0x0000)
if reset:
# Reset to all inputs and no inverted polarity.
self.iodir = 0xFFFF
self._write_u16le(_MCP23016_IPOL0, 0x0000)

@property
def gpio(self):
Expand Down
13 changes: 7 additions & 6 deletions adafruit_mcp230xx/mcp23017.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ class MCP23017(MCP230XX):
at the specified I2C address.
"""

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

@property
def gpio(self):
Expand Down