1+ print ("Starting" )
2+
3+ # Import all the IOs of the board
4+ import board
5+ print (dir (board )) #check that the pin names are the same as the pins defined below
6+
7+ # Imports from the kmk library
8+ from kmk .kmk_keyboard import KMKKeyboard
9+ from kmk .scanners .keypad import KeysScanner
10+ from kmk .keys import KC
11+ from kmk .extensions .rgb import RGB
12+ from kmk .modules .layers import Layers
13+ # from kmk.modules.macros import Press, Release, Tap, Macros
14+
15+ # Main instance of keyboard
16+ keyboard = KMKKeyboard ()
17+
18+ keyboard .modules .append (Layers ())
19+
20+ # Add the macro extension
21+ # macros = Macros()
22+ # keyboard.modules.append(macros)
23+
24+ #Define the RGB pin
25+ rgb = RGB (rgb_pixel_pin = board .SDA , num_pixels = 3 )
26+ keyboard .extensions .append (rgb )
27+
28+ # Define the pins
29+ PINS = [board .SCK , board .MISO , board .MOSI , board .RX ]
30+
31+ # Tell kmk we are not using a key matrix
32+ keyboard .matrix = KeysScanner (
33+ pins = PINS ,
34+ value_when_pressed = False ,
35+ )
36+
37+ RAISE = KC .LT (1 , KC .ESCAPE )
38+ LOWER = KC .LT (0 , KC .RGB_TOG )
39+
40+ # Define the buttons corresponding to the pins
41+ # Keycodes: https://github.com/KMKfw/kmk_firmware/blob/main/docs/en/keycodes.md
42+ # Macros: https://github.com/KMKfw/kmk_firmware/blob/main/docs/en/macros.md
43+ keyboard .keymap = [
44+ [#layer 0
45+ KC .PAUSE , KC .DELETE , KC .SPACE , RAISE ,
46+ ],
47+ [#layer 1
48+ KC .RGB_MODE_BREATHE_RAINBOW , KC .RGB_HUI , KC .RGB_MODE_SWIRL , LOWER ,
49+ ],
50+
51+ ]
52+
53+ # Start kmk!
54+ if __name__ == '__main__' :
55+ keyboard .go ()
0 commit comments