Able to build a VERY basic KMK image for Feather M4 Express, flashable over UF2 only
This commit is contained in:
@@ -2,6 +2,7 @@ import digitalio
|
||||
|
||||
from kmk.common.abstract.matrix_scanner import AbstractMatrixScanner
|
||||
from kmk.common.consts import DiodeOrientation
|
||||
from kmk.common.event_defs import matrix_changed
|
||||
|
||||
|
||||
class MatrixScanner(AbstractMatrixScanner):
|
||||
@@ -17,6 +18,7 @@ class MatrixScanner(AbstractMatrixScanner):
|
||||
self.cols = [digitalio.DigitalInOut(pin) for pin in cols]
|
||||
self.rows = [digitalio.DigitalInOut(pin) for pin in rows]
|
||||
self.diode_orientation = diode_orientation
|
||||
self.last_pressed_len = 0
|
||||
|
||||
if self.diode_orientation == DiodeOrientation.COLUMNS:
|
||||
self.outputs = self.cols
|
||||
@@ -35,15 +37,22 @@ class MatrixScanner(AbstractMatrixScanner):
|
||||
for pin in self.inputs:
|
||||
pin.switch_to_input(pull=digitalio.Pull.DOWN)
|
||||
|
||||
def _normalize_matrix(self, matrix):
|
||||
return super()._normalize_matrix(matrix)
|
||||
def scan_for_pressed(self):
|
||||
pressed = []
|
||||
|
||||
def raw_scan(self):
|
||||
matrix = []
|
||||
|
||||
for opin in self.outputs:
|
||||
for oidx, opin in enumerate(self.outputs):
|
||||
opin.value = True
|
||||
matrix.append([ipin.value for ipin in self.inputs])
|
||||
|
||||
for iidx, ipin in enumerate(self.inputs):
|
||||
if ipin.value:
|
||||
pressed.append(
|
||||
(oidx, iidx) if self.diode_orientation == DiodeOrientation.ROWS else (iidx, oidx) # noqa
|
||||
)
|
||||
|
||||
opin.value = False
|
||||
|
||||
return self._normalize_matrix(matrix)
|
||||
if len(pressed) != self.last_pressed_len:
|
||||
self.last_pressed_len = len(pressed)
|
||||
return matrix_changed(pressed)
|
||||
|
||||
return None # The default, but for explicitness
|
||||
|
Reference in New Issue
Block a user