Add neopixel mixin to SwitchMatrix, change to COL2ROW#517
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the keyboard switch-matrix implementation to use a hierarchical per-switch “cell” block, switches the matrix generator to a COL2ROW convention, and adds an optional neopixel-chain mixin for per-key lighting. It also updates example designs and their generated/reference outputs to reflect the new hierarchy and connectivity (including adding USB ESD protection in the keyboard example).
Changes:
- Refactor
SwitchMatrixto generateSwitchCellinstances (switch + diode), enabling hierarchical replication and adding an optional neopixel chain (SwitchMatrixNeopixels). - Change matrix scanning convention to COL2ROW and update generated SVGPCB/netlist reference outputs for examples.
- Update examples to include neopixels (keyboard) and add a KiCad footprint library table for the custom
edg.prettyfootprints.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/test_keyboard.py | Adds USB ESD diode in the USB chain; adds neopixel mixin wiring + refinements for neopixel part/current. |
| examples/Keyboard/Keyboard.svgpcb.js | Updates generated placement/netlist for keyboard example (now includes neopixels, USB ESD, level shifter). |
| examples/Keyboard/Keyboard.net.ref | Updates reference netlist for new switch-cell hierarchy + neopixel parts + USB ESD. |
| examples/Keyboard/fp-lib-table | Adds local KiCad footprint library table entry for edg.pretty. |
| examples/DeskController/DeskController.svgpcb.js | Updates generated netlist naming/pin mapping to match COL2ROW switch-matrix changes. |
| examples/DeskController/DeskController.net.ref | Updates reference netlist for switch-cell hierarchy / connectivity changes. |
| examples/BasicKeyboard/BasicKeyboard.svgpcb.js | Updates generated netlist naming/pin mapping to match COL2ROW switch-matrix changes. |
| examples/BasicKeyboard/BasicKeyboard.net.ref | Updates reference netlist for switch-cell hierarchy / connectivity changes. |
| edg/parts/human_interface/Neopixel.py | Removes abstract Neopixel base from this file (now lives in abstract_parts). |
| edg/circuits/SwitchMatrix.py | Major refactor: adds SwitchCell, COL2ROW behavior, and neopixel-chain mixin; updates svgpcb template pin lookups for new hierarchy. |
| edg/circuits/init.py | Re-exports SwitchMatrixNeopixels. |
| edg/BoardTop.py | Adds default refinement mapping Neopixel -> Ws2812b. |
| edg/abstract_parts/Neopixel.py | Introduces abstract Neopixel base in abstract parts. |
| edg/abstract_parts/init.py | Re-exports Neopixel. |
Comments suppressed due to low confidence (1)
examples/Keyboard/Keyboard.svgpcb.js:309
- The switch-matrix trace generator function wires the column bus to switch pad 2 and the row bus to diode pad 2, but the netlist above connects matrix columns to switch pad 1 (mcu.gpio.0_x nets) and rows to diode pad 1 (mcu.gpio.1_x nets). This means the generated copper won't match the netlist for the keyboard example.
// create stub wire for button -> column common line
colWirePoint = [buttonPos[0], button.padY("2")]
board.wire([colWirePoint, button.pad("2")], traceSize, "F.Cu")
colWirePoints.push(colWirePoint)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+61
to
+64
| self.npx_din = self.Port(DigitalSink.empty()) | ||
| self.npx_dout = self.Port(DigitalSource.empty(), optional=True) | ||
| self.npx_pwr = self.Port(VoltageSink.empty()) | ||
| self.npx_gnd = self.Port(Ground.empty()) |
Comment on lines
+246
to
+249
| self.npx_din = self.Port(DigitalSink.empty()) | ||
| self.npx_dout = self.Port(DigitalSource.empty(), optional=True) | ||
| self.npx_pwr = self.Port(VoltageSink.empty()) | ||
| self.npx_gnd = self.Port(Ground.empty()) |
| (Neopixel, Sk6812Mini_E), | ||
| (RotaryEncoder, Pec11s), | ||
| ], | ||
| instance_values=[(["mcu", "pin_assigns"], [])], # TODO pining: NPX must be SPI MOSI |
Comment on lines
+119
to
+123
| switch_sw_pin = self._svgpcb_pin_of(["sw[0,0]", "sw"], ["sw"]) | ||
| switch_com_pin = self._svgpcb_pin_of(["sw[0,0]", "sw"], ["com"]) | ||
| diode_footprint = self._svgpcb_footprint_of(diode_block) | ||
| diode_a_pin = self._svgpcb_pin_of(["d[0,0]"], ["anode"]) | ||
| diode_k_pin = self._svgpcb_pin_of(["d[0,0]"], ["cathode"]) | ||
| diode_a_pin = self._svgpcb_pin_of(["sw[0,0]", "d"], ["anode"]) | ||
| diode_k_pin = self._svgpcb_pin_of(["sw[0,0]", "d"], ["cathode"]) |
Comment on lines
+11
to
+15
| {name: "mcu.gpio.0_0", pads: [["U1", "7"], ["SW1", "1"], ["SW2", "1"], ["SW3", "1"]]}, | ||
| {name: "mcu.gpio.0_1", pads: [["U1", "8"], ["SW4", "1"], ["SW5", "1"], ["SW6", "1"]]}, | ||
| {name: "mcu.gpio.1_0", pads: [["U1", "9"], ["D1", "1"], ["D4", "1"]]}, | ||
| {name: "mcu.gpio.1_1", pads: [["U1", "11"], ["D2", "1"], ["D5", "1"]]}, | ||
| {name: "mcu.gpio.1_2", pads: [["U1", "10"], ["D3", "1"], ["D6", "1"]]}, |
Comment on lines
+328
to
+332
| {name: "Dmcu.gpio.swc_0", pads: [["DU2", "5"], ["DSW1", "1"], ["DSW2", "1"], ["DSW3", "1"]]}, | ||
| {name: "Dmcu.gpio.swc_1", pads: [["DU2", "15"], ["DSW4", "1"], ["DSW5", "1"], ["DSW6", "1"]]}, | ||
| {name: "Dmcu.gpio.swr_0", pads: [["DU2", "14"], ["DD2", "1"], ["DD5", "1"]]}, | ||
| {name: "Dmcu.gpio.swr_1", pads: [["DU2", "13"], ["DD3", "1"], ["DD6", "1"]]}, | ||
| {name: "Dmcu.gpio.swr_2", pads: [["DU2", "10"], ["DD4", "1"], ["DD7", "1"]]}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes SwitchMatrix to use a SwitchCell internally, which encapsulates the switch and diode for hierarchical layout replication.
Changes the generator to follow the more common COL2ROW convention, with no deprecation path. Adds neopixels as an optional mixin.
Updates the keyboard example, which will be routed in a future PR.
This does not update the layout generators. The layout generators are also likely brittle to the refdes change from neopixels, if used.