1- # You import all the IOs of your board
21import board
3-
4- # These are imports from the kmk library
2+ import busio
53from kmk .kmk_keyboard import KMKKeyboard
64from kmk .scanners import DiodeOrientation
75from kmk .keys import KC
8- from kmk .modules .macros import Press , Release , Tap , Macros
6+ from kmk .modules .encoder import EncoderHandler
7+ from kmk .extensions .display import Display , TextEntry , ImageEntry
8+ from kmk .extensions .display .ssd1306 import SSD1306
9+ from kmk .extensions .RGB import RGB
910
10- # This is the main instance of your keyboard
1111keyboard = KMKKeyboard ()
1212
13- # Add the macro extension
14- macros = Macros ()
15- keyboard .modules .append (macros )
13+ encoder = EncoderHandler ()
14+ encoder_handler .pins = ((board .SCK , board .RX , None ,),)
15+ encoder_handler .map = [((KC .VOLD , KC .VOLU , KC .NO ,),)]
16+ keyboard .modules .append (encoder )
1617
17- # Define your pins here!
18- keyboard .col_pins = (board .A0 , board .A1 , board .A2 )
19- keyboard .row_pins = (board .A3 , board .MISO , board .MOSI )
20- keyboard .diode_orientation = DiodeOrientation .COL2ROW
18+ i2c_bus = busio .I2C (board .SCL , board .SDA )
19+ display_driver = SSD1306 (i2c = i2c_bus )
20+ display = Display (display = display_driver )
21+ display .entries = [
22+ ImageEntry (image = "pfptiny.bmp" , x = 0 , y = 0 ),
23+ TextEntry (text = "bfpad" , x = 40 , y = 16 , y_anchor = "M" )
24+ ]
25+ keyboard .extensions .append (display )
2126
22- # Here you define the buttons corresponding to the pins
23- # Look here for keycodes: https://github.com/KMKfw/kmk_firmware/blob/main/docs/en/keycodes.md
24- # And here for macros: https://github.com/KMKfw/kmk_firmware/blob/main/docs/en/macros.md
27+ rgb = RGB (pixel_pin = board .TX , num_pixels = 11 )
28+ keyboard .extensions .append (rgb )
29+
30+ keyboard .col_pins = (board .MOSI , board .A0 , board .MISO )
31+ keyboard .row_pins = (board .A3 , board .A2 , board .A1 )
32+ keyboard .diode_orientation = DiodeOrientation .COL2ROW
2533keyboard .keymap = [
26- [[KC .RABK , KC .DOT , KC .COMMA ], [KC .LABK , KC .PLUS , KC .LBRACKET ], [KC .MINUS , KC .NO , KC .RBRACKET ]]
34+ [[KC .RABK , KC .DOT , KC .COMMA ], [KC .LABK , KC .PLUS , KC .LBRACKET ], [KC .MINUS , KC .MUTE , KC .RBRACKET ]]
2735]
2836
29- # Start kmk!
3037if __name__ == '__main__' :
3138 keyboard .go ()
0 commit comments