From e3a4dc7bc8de0ffb7253056e5835fdea3316a2c6 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Tue, 18 Oct 2022 05:04:55 +0200 Subject: [PATCH] pylint... --- examples/mcp23017_scanner_keys.py | 2 +- mcp23017_scanner.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/mcp23017_scanner_keys.py b/examples/mcp23017_scanner_keys.py index 15e9994..21b8766 100644 --- a/examples/mcp23017_scanner_keys.py +++ b/examples/mcp23017_scanner_keys.py @@ -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() diff --git a/mcp23017_scanner.py b/mcp23017_scanner.py index 342a056..930bf80 100644 --- a/mcp23017_scanner.py +++ b/mcp23017_scanner.py @@ -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() @@ -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. @@ -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