equals.c (1489B)
1 // Copyright 2023 @boardsource 2 // SPDX-License-Identifier: GPL-2.0-or-later 3 4 #include "quantum.h" 5 6 #ifdef QUANTUM_PAINTER_ENABLE 7 #include "qp.h" 8 #include "qp_st7735.h" 9 #include "graphics/thintel15.qff.c" 10 11 static painter_device_t oled; 12 static painter_font_handle_t font; 13 14 __attribute__((weak)) void ui_init(void) { 15 oled = qp_st7735_make_spi_device(128, 160, OLED_CS_PIN, OLED_DC_PIN, OLED_RST_PIN, 8, 0); 16 font = qp_load_font_mem(font_thintel15); 17 qp_init(oled, QP_ROTATION_0); 18 qp_rect(oled, 0, 0, 130, 162, 0, 0, 0, true); 19 qp_rect(oled, 20, 20, 108, 60, 55, 55, 55, true); 20 qp_rect(oled, 20, 80, 108, 120, 55, 55, 55, true); 21 qp_flush(oled); 22 } 23 24 __attribute__((weak)) void ui_task(void) { 25 static const char *text = "Layer:"; 26 int16_t width = qp_textwidth(font, text); 27 qp_drawtext(oled, 20, 140, font, text); 28 29 switch (get_highest_layer(layer_state)) { 30 case 0: 31 qp_drawtext(oled, (20 + width), 140, font, "QWERTY"); 32 break; 33 case 1: 34 qp_drawtext(oled, (20 + width), 140, font, "SYMBOL"); 35 break; 36 case 2: 37 qp_drawtext(oled, (20 + width), 140, font, "NUMBER"); 38 break; 39 default: 40 qp_drawtext(oled, (20 + width), 140, font, "_PANIC_"); 41 break; 42 } 43 } 44 45 void keyboard_post_init_kb(void) { 46 ui_init(); 47 keyboard_post_init_user(); 48 } 49 50 void housekeeping_task_kb(void) { 51 ui_task(); 52 } 53 #endif // QUANTUM_PAINTER_ENABLE