From 85ab403d223aac1a8ddf48aa6572680dffc81aea Mon Sep 17 00:00:00 2001 From: Josh Klar Date: Thu, 18 Oct 2018 23:33:04 -0700 Subject: [PATCH] More clear matrix scan function --- kmk/firmware.py | 2 +- kmk/matrix.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kmk/firmware.py b/kmk/firmware.py index 6ba2399..32af927 100644 --- a/kmk/firmware.py +++ b/kmk/firmware.py @@ -94,7 +94,7 @@ class Firmware: print("Firin' lazers. Keyboard is booted.") while True: - for update in self.matrix.scan_for_pressed(): + for update in self.matrix.scan_for_changes(): if update is not None: self._state.matrix_changed( update[0], diff --git a/kmk/matrix.py b/kmk/matrix.py index 448ca73..0b428e6 100644 --- a/kmk/matrix.py +++ b/kmk/matrix.py @@ -59,7 +59,13 @@ class MatrixScanner: self.state = bytearray(self.len_state_arrays) self.report = bytearray(3) - def scan_for_pressed(self): + def scan_for_changes(self): + ''' + Poll the matrix for changes and return either None (if nothing updated) + or a bytearray (reused in later runs so copy this if you need the raw + array itself for some crazy reason) consisting of (row, col, pressed) + which are (int, int, bool) + ''' ba_idx = 0 any_changed = False