mini42.c (3988B)
1 /* 2 * Copyright 2022 Kevin Gee <info@controller.works> 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "quantum.h" 19 20 #ifdef OLED_ENABLE 21 22 static void render_logo(void) { 23 static const char PROGMEM raw_logo[] = { 24 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0,128,192, 96, 48, 24, 12,254,254, 0, 0, 0, 0, 0, 0, 48, 24, 12, 6, 6, 6, 6, 6, 6, 12, 24,240,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,248,252, 6, 3, 3, 3, 3, 7,254,252, 6, 3, 3, 3, 3, 6,252,248, 0, 0, 0, 0, 0, 0,255,255, 0, 0, 0, 0, 0, 0,248,252, 6, 3, 3, 3, 3, 3, 3, 6,252,248, 0, 0, 0, 0, 0, 0,255,255, 0, 0, 0, 0, 24, 28, 30, 27, 25, 24, 24, 24, 24, 24,255,255, 24, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,192, 96, 48, 24, 15, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0, 0, 0, 0, 96,112,120,108,102, 99, 97, 96, 96, 96, 96, 96, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27 }; 28 oled_write_raw_P(raw_logo, sizeof(raw_logo)); 29 } 30 31 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { 32 if (!is_keyboard_master()) { 33 return OLED_ROTATION_180; // flips the display 180 degrees if offhand 34 } 35 36 return rotation; 37 } 38 39 bool render_status(void) { 40 // Host Keyboard Layer Status 41 oled_write_P(PSTR("Layer: "), false); 42 43 switch (get_highest_layer(layer_state)) { 44 case 0: 45 oled_write_P(PSTR("BASE\n"), false); 46 break; 47 case 1: 48 oled_write_P(PSTR("LOWER\n"), false); 49 break; 50 case 2: 51 oled_write_P(PSTR("RAISE\n"), false); 52 break; 53 case 3: 54 oled_write_P(PSTR("ADJUST\n"), false); 55 break; 56 default: 57 // Or use the write_ln shortcut over adding '\n' to the end of your string 58 oled_write_ln_P(PSTR("Undefined"), false); 59 } 60 61 // Host Keyboard LED Status 62 led_t led_state = host_keyboard_led_state(); 63 oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); 64 oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false); 65 oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false); 66 67 return false; 68 } 69 70 bool oled_task_kb(void) { 71 if (!oled_task_user()) { 72 return false; 73 } 74 if (is_keyboard_master()) { 75 render_status(); // Renders the current keyboard state (layer, lock, caps, scroll, etc) 76 } else { 77 render_logo(); // Renders a static logo 78 oled_scroll_left(); // Turns on scrolling 79 } 80 return false; 81 } 82 83 #endif