Skip to content

Commit 3267a47

Browse files
Merge pull request #38 from flyte/feature/mcp23017-intcap
Add INTCAP register access
2 parents a15521a + 6317393 commit 3267a47

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

adafruit_mcp230xx/mcp23017.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,31 @@ def int_flagb(self):
289289
flags = [pin + 8 for pin in range(8) if intfb & (1 << pin)]
290290
return flags
291291

292+
@property
293+
def int_cap(self):
294+
"""Returns a list with the pin values at time of interrupt
295+
port A ----> pins 0-7
296+
port B ----> pins 8-15
297+
"""
298+
intcap = self._read_u16le(_MCP23017_INTCAPA)
299+
return [(intcap >> pin) & 1 for pin in range(16)]
300+
301+
@property
302+
def int_capa(self):
303+
"""Returns a list of pin values at time of interrupt
304+
pins: 0-7
305+
"""
306+
intcapa = self._read_u8(_MCP23017_INTCAPA)
307+
return [(intcapa >> pin) & 1 for pin in range(8)]
308+
309+
@property
310+
def int_capb(self):
311+
"""Returns a list of pin values at time of interrupt
312+
pins: 8-15
313+
"""
314+
intcapb = self._read_u8(_MCP23017_INTCAPB)
315+
return [(intcapb >> pin) & 1 for pin in range(8)]
316+
292317
def clear_ints(self):
293318
"""Clears interrupts by reading INTCAP."""
294319
self._read_u16le(_MCP23017_INTCAPA)

0 commit comments

Comments
 (0)