Skip to content

Commit

Permalink
pylint...
Browse files Browse the repository at this point in the history
  • Loading branch information
Neradoc committed Oct 18, 2022
1 parent dc539da commit e3a4dc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/mcp23017_scanner_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
PINS = [0, 1, 2, 3, 4, 10, 11, 12, 13, 14]

mcp = MCP23017(board.I2C())
scanner = McpKeysScanner(mcp, PINS) # , irq=board.D5)
scanner = McpKeysScanner(mcp, PINS) # , irq=board.D5)

while True:
t0 = ticks_ms()
Expand Down
17 changes: 12 additions & 5 deletions mcp23017_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,16 @@ def __len__(self) -> int:


class McpScanner:
"""
Base class for MCP scanners.
"""

def __init__(self,
def __init__(
self,
mcp: any,
irq: Optional[Pin] = None,
):
self._key_count = 0
self.mcp = mcp
self.keys_state = set()
self.events = EventQueue()
Expand All @@ -155,6 +160,9 @@ def key_count(self) -> int:
"""The number of keys in the scanner."""
return self._key_count

def _scan_pins(self) -> Set[int]: # pylint:disable=no-self-use
return Set()

def update(self) -> None:
"""
Run the scan and create events in the event queue.
Expand Down Expand Up @@ -297,8 +305,7 @@ def _scan_pins(self) -> Set[int]:
"""Scan the buttons and return the list of keys down"""
pressed = set()
inputs = self.mcp.gpio & self.pin_bits
for scan in self.pins:
for pin in self.pins:
if inputs & (1 << pin) == 0:
pressed.add(pin)
for pin in self.pins:
if inputs & (1 << pin) == 0:
pressed.add(pin)
return pressed

0 comments on commit e3a4dc7

Please sign in to comment.