qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

mini36.c (3986B)


      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 #include "quantum.h"
     18 
     19 #ifdef OLED_ENABLE
     20 
     21 static void render_logo(void) {
     22     static const char PROGMEM raw_logo[] = {
     23         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,  6,  6,  6,  6,  6,134,230,126, 30,  6,  0,  0,  0,  0,  0,128,192, 96, 56, 28,  6,  2,  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,
     24         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,  0,  0,  0,  0,  0,  0, 28, 31, 27, 24, 48,224,192,  0,  0,240,252, 62, 27, 25, 24, 24, 24, 24, 48,224,192,  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, 
     25         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, 12, 24, 48, 96, 96, 96, 96, 96, 96, 48, 31, 15,  0,  0, 15, 31, 48, 96, 96, 96, 96, 96, 96, 48, 31, 15,  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     };
     27     oled_write_raw_P(raw_logo, sizeof(raw_logo));
     28 }
     29 
     30 oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
     31     if (!is_keyboard_master()) {
     32         return OLED_ROTATION_180;  // flips the display 180 degrees if offhand
     33     }
     34 
     35     return rotation;
     36 }
     37 
     38 bool render_status(void) {
     39     // Host Keyboard Layer Status
     40     oled_write_P(PSTR("Layer: "), false);
     41 
     42     switch (get_highest_layer(layer_state)) {
     43         case 0:
     44             oled_write_P(PSTR("BASE\n"), false);
     45             break;
     46         case 1:
     47             oled_write_P(PSTR("LOWER\n"), false);
     48             break;
     49         case 2:
     50             oled_write_P(PSTR("RAISE\n"), false);
     51             break;
     52         case 3:
     53             oled_write_P(PSTR("ADJUST\n"), false);
     54             break;            
     55         default:
     56             // Or use the write_ln shortcut over adding '\n' to the end of your string
     57             oled_write_ln_P(PSTR("Undefined"), false);
     58     }
     59 
     60     // Host Keyboard LED Status
     61     led_t led_state = host_keyboard_led_state();
     62     oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR("    "), false);
     63     oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR("    "), false);
     64     oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR("    "), false);
     65     
     66     return false;
     67 }
     68 
     69 bool oled_task_kb(void) {
     70     if (!oled_task_user()) {
     71         return false;
     72     }
     73     if (is_keyboard_master()) {
     74         render_status();  // Renders the current keyboard state (layer, lock, caps, scroll, etc)
     75     } else {
     76         render_logo();  // Renders a static logo
     77         oled_scroll_left();  // Turns on scrolling
     78     }
     79     return false;
     80 }
     81 
     82 #endif