Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix digitalio matrix orientation #927

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix digitalio matrix orientation
  • Loading branch information
regicidalplutophage authored Jan 8, 2024
commit 1c4d3532cd726670735ba8480193bc239457e6aa
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
Loading