Add Numerical Keypad support from Bolt Industries

This commit is contained in:
Davi Gupta 2023-01-10 22:28:49 -08:00 committed by xs5871
parent d8867004ff
commit 407de4c429
3 changed files with 89 additions and 0 deletions

10
boards/Pico14/README.md Normal file
View File

@ -0,0 +1,10 @@
# Pico 14 Numerical Keypad
![Pico14](https://www.boltind.com/wp-content/uploads/2022/01/PXL_20220119_171113903-scaled.jpg)
Pico 14 Numerical Keypad / Macro Pad PCBs and Hardware Kit.
`kb.py` is designed to work with the Pi Pico.
Retailers:
[Bolt Industries](https://www.boltind.com/product/pico-14-numerical-keypad-macro-pad-pcbs-and-hardware-kit/)

23
boards/Pico14/kb.py Normal file
View File

@ -0,0 +1,23 @@
import board
from kmk.kmk_keyboard import KMKKeyboard as _KMKKeyboard
from kmk.scanners import DiodeOrientation
class KMKKeyboard(_KMKKeyboard):
col_pins = (
board.GP0,
board.GP1,
board.GP2,
)
row_pins = (
board.GP18,
board.GP19,
board.GP20,
board.GP21,
board.GP22,
)
diode_orientation = DiodeOrientation.COLUMNS
led_pin = board.GP27

56
boards/Pico14/main.py Normal file
View File

@ -0,0 +1,56 @@
from kb import KMKKeyboard
from kmk.extensions.LED import LED
from kmk.extensions.lock_status import LockStatus
from kmk.keys import KC
from kmk.modules.layers import Layers
Pico14 = KMKKeyboard()
class LEDLockStatus(LockStatus):
def __init__(self, leds):
super().__init__()
self._leds = leds
def set_lock_leds(self):
if self.get_num_lock():
self._leds.set_brightness(100, leds=[0])
else:
self._leds.set_brightness(0, leds=[0])
def after_hid_send(self, sandbox):
super().after_hid_send(sandbox) # Critically important. Removing this will break lock status.
if self.report_updated:
self.set_lock_leds()
Pico14.modules.append(Layers())
leds = LED(led_pin=[Pico14.led_pin], val=0)
Pico14.extensions.append(leds)
Pico14.extensions.append(LEDLockStatus(leds))
# Make this for better looking formatting...
______ = KC.TRNS
XXXXXX = KC.NO
Pico14.keymap = [[
# Layer 0 QWERTY
KC.NUMLOCK, KC.NUMPAD_SLASH, KC.NUMPAD_ASTERISK,
KC.NUMPAD_7, KC.NUMPAD_8, KC.NUMPAD_9,
KC.NUMPAD_4, KC.NUMPAD_5, KC.NUMPAD_6,
KC.NUMPAD_1, KC.NUMPAD_2, KC.NUMPAD_1,
KC.NUMPAD_0, XXXXXX, KC.NUMPAD_DOT
], [
# Layer 1
______, ______, ______,
KC.HOME, KC.UP, KC.PGUP,
KC.LEFT, ______, KC.RIGHT,
KC.END, KC.DOWN, KC.PGDN,
KC.INS, XXXXXX, KC.DEL
]
]
if __name__ == '__main__':
Pico14.go()