Skip to content

Refactor keyboard setup with matrix scanner#1

Open
kusuta012 wants to merge 2 commits intoalexlam0206:masterfrom
kusuta012:patch-1
Open

Refactor keyboard setup with matrix scanner#1
kusuta012 wants to merge 2 commits intoalexlam0206:masterfrom
kusuta012:patch-1

Conversation

@kusuta012
Copy link

@kusuta012 kusuta012 commented Feb 2, 2026

Updated keyboard configuration to use a matrix scanner with defined pins.

Closes #

📑 Description

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation (PLEASE STATE)
  • I have updated the documentation as required

ℹ Additional Information

Summary by CodeRabbit

  • Refactor
    • Updated the keyboard scanning/configuration to use a matrix-based mechanism for improved hardware scanning reliability and performance; existing shortcuts and keymap remain unchanged.
    • Minor change to initialization order during startup to support the new scanning approach.

Updated keyboard configuration to use a matrix scanner with defined pins.
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Replaces explicit row_pins, col_pins, and diode_orientation in Firmware/main.py with a consolidated PINS list and sets keyboard.matrix = KeysScanner(pins=PINS, value_when_pressed=False). Adds KeysScanner import and initializes matrix-based scanning before keymap/mac shortcuts remain unchanged.

Changes

Cohort / File(s) Summary
Keyboard Matrix Configuration
Firmware/main.py
Added KeysScanner import; removed separate row_pins, col_pins, and diode_orientation tuples; introduced PINS list and keyboard.matrix = KeysScanner(pins=PINS, value_when_pressed=False); preserved existing Mac shortcuts and keymap definitions; initialization order updated to configure matrix before keymap setup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nudged the pins into a single line,
KeysScanner hums, detecting every sign,
Rows and cols now friends in a list,
A tidy scan — a rabbit's little twist! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the primary change: refactoring the keyboard setup to use a matrix scanner instead of explicit pin configuration.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@Firmware/main.py`:
- Around line 12-13: The code uses KeysScanner when assigning keyboard.matrix
but never imports it; add the missing import statement for KeysScanner from the
KMK scanners module (e.g., import KeysScanner from kmk.scanners) so KeysScanner
is defined before PINS and keyboard.matrix are used.
- Around line 12-13: Import KeysScanner and update imports by adding from
kmk.scanners.keypad import KeysScanner, then use KeysScanner as before
(keyboard.matrix = KeysScanner(pins=PINS, value_when_pressed=False)); ensure the
PINS list order exactly matches the keymap sequence used later (PINS =
[board.SCL, board.TX, board.RX, board.SCK, board.MISO, board.MOSI] must align
with the keymap entries) and remove or correct any comments about diode
orientation since diode orientation guidance applies to matrix scanners, not
KeysScanner.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@Firmware/main.py`:
- Line 6: Remove the stray diff marker causing the syntax error by fixing the
import line in main.py: replace the invalid line that contains "+from
kmk.scanners.keypad import KeysScanner" with a proper Python import "from
kmk.scanners.keypad import KeysScanner" so the KeysScanner symbol is imported
without the leading '+' character.

from kmk.keys import KC
from kmk.modules.macros import Macros
from kmk.handlers.sequences import simple_key_sequence
+from kmk.scanners.keypad import KeysScanner
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix the invalid syntax on the KeysScanner import.

Ruff reports invalid syntax at Line 6. Ensure there’s no stray leading character (e.g., a + diff marker) before the from statement in the committed file.

🛠️ Proposed fix
-+from kmk.scanners.keypad import KeysScanner
+from kmk.scanners.keypad import KeysScanner
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
+from kmk.scanners.keypad import KeysScanner
from kmk.scanners.keypad import KeysScanner
🧰 Tools
🪛 Ruff (0.14.14)

[warning] 6-6: Expected an identifier, but found a keyword from that cannot be used here

(invalid-syntax)


[warning] 6-6: Simple statements must be separated by newlines or semicolons

(invalid-syntax)


[warning] 6-6: Simple statements must be separated by newlines or semicolons

(invalid-syntax)

🤖 Prompt for AI Agents
In `@Firmware/main.py` at line 6, Remove the stray diff marker causing the syntax
error by fixing the import line in main.py: replace the invalid line that
contains "+from kmk.scanners.keypad import KeysScanner" with a proper Python
import "from kmk.scanners.keypad import KeysScanner" so the KeysScanner symbol
is imported without the leading '+' character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant