Skip to content

Commit d9a7749

Browse files
committed
Cleaned code, switched list to tuple, renamed to code.py
1 parent f617440 commit d9a7749

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Pico_RP2040_Mech_Keyboard/pico_mech_keyboard.py Pico_RP2040_Mech_Keyboard/code.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
cc = ConsumerControl(usb_hid.devices)
2222

2323
# list of pins to use (skipping GP15 on Pico because it's funky)
24-
pins = [
24+
pins = (
2525
board.GP0,
2626
board.GP1,
2727
board.GP2,
@@ -43,7 +43,7 @@
4343
board.GP19,
4444
board.GP20,
4545
board.GP21,
46-
]
46+
)
4747

4848
MEDIA = 1
4949
KEY = 2
@@ -74,14 +74,14 @@
7474
(20): (KEY, [Keycode.U]),
7575

7676
}
77-
switches = [0, 1, 2, 3, 4, 5, 6,
78-
7, 8, 9, 10, 11, 12, 13,
79-
14, 15, 16, 17, 18, 19, 20, 21]
80-
81-
for i in range(21):
82-
switches[i] = DigitalInOut(pins[i])
83-
switches[i].direction = Direction.INPUT
84-
switches[i].pull = Pull.UP
77+
78+
switches = []
79+
for i in range(len(pins)):
80+
switch = DigitalInOut(pins[i])
81+
switch.direction = Direction.INPUT
82+
switch.pull = Pull.UP
83+
switches.append(switch)
84+
8585

8686
switch_state = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
8787

0 commit comments

Comments
 (0)