Skip to content

Commit

Permalink
Fix digitalio matrix orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
regicidalplutophage authored Jan 8, 2024
1 parent d821f36 commit 1c4d353
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kmk/scanners/digitalio.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def __init__(
self,
cols,
rows,
diode_orientation=DiodeOrientation.COLUMNS,
pull=digitalio.Pull.DOWN,
diode_orientation=DiodeOrientation.COL2ROW,
pull=digitalio.Pull.UP,
rollover_cols_every_rows=None,
offset=0,
):
Expand All @@ -36,7 +36,7 @@ def __init__(
# does not use the digitalio.DigitalInOut, but rather a self defined one:
# https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx/blob/3f04abbd65ba5fa938fcb04b99e92ae48a8c9406/adafruit_mcp230xx/digital_inout.py#L33

if self.diode_orientation == DiodeOrientation.COLUMNS:
if self.diode_orientation == DiodeOrientation.COL2ROW:
self.anodes = [
x
if x.__class__.__name__ == 'DigitalInOut'
Expand All @@ -50,7 +50,7 @@ def __init__(
for x in rows
]
self.translate_coords = True
elif self.diode_orientation == DiodeOrientation.ROWS:
elif self.diode_orientation == DiodeOrientation.ROW2COL:
self.anodes = [
x
if x.__class__.__name__ == 'DigitalInOut'
Expand All @@ -73,6 +73,7 @@ def __init__(
elif self.pull == digitalio.Pull.UP:
self.outputs = self.cathodes
self.inputs = self.anodes
self.translate_coords = not self.translate_coords
else:
raise ValueError(f'Invalid pull: {self.pull}')

Expand Down

0 comments on commit 1c4d353

Please sign in to comment.