qmk_firmware

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

uma.c (5479B)


      1 /* Copyright 2021 duoshock 
      2  * 
      3  * This program is free software: you can redistribute it and/or modify 
      4  * it under the terms of the GNU General Public License as published by 
      5  * the Free Software Foundation, either version 2 of the License, or 
      6  * (at your option) any later version. 
      7  * 
      8  * This program is distributed in the hope that it will be useful, 
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     11  * GNU General Public License for more details. 
     12  * 
     13  * You should have received a copy of the GNU General Public License 
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 
     17 #include "quantum.h"
     18 
     19 #ifdef OLED_ENABLE
     20 void suspend_power_down_user(void) {
     21     oled_off();
     22 }
     23 
     24 oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
     25     if (is_keyboard_master()) {
     26         return OLED_ROTATION_90;
     27     }
     28 
     29     return rotation;
     30 }
     31 
     32 static void render_logo(void) {
     33     static const char PROGMEM raw_logo[] = {
     34         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,128,192,192,224,224,224,224,224,224,224,224,224,224,224,224,224,224,192,192,128,128,192,192,224,224,224,224,224,224,224,224,192,192,128,  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,  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,
     35         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 15,  3,  1,  0,  1,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,252,240,  0,  0,  0,  0,  0,  0,  0,  0,  0,254,254,254,  0,  0,  0,  0,  0,  0,254,254,254,  0,  0,  0,254,254,254,252,240,224,128,128,224,240,252,254,254,254,  0,  0,128,128,128,128,128,128,  0,  0,  0,  0,  0,224,248,252, 62, 62,252,240,192,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
     36         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,240,192,128,  0,128,255,255,255,255,255,255,255,255,255,255,255,255,255,255,127, 63, 15,  0,  0,  0,  0,  0,  0,  0,  0,  0, 15, 31, 63,120,112,112,112,112,120, 63, 31, 15,  0,  0,  0,127,127,127,  0,  1,  7,  7,  7,  7,  1,  0,127,127,127,  0,  0,  3,  3,  3,  3,  3,  3,  1,  0,112,124,127, 31, 15, 14, 14, 14, 15, 15, 31,127,124, 32,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 
     37         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  3,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  3,  3,  1,  1,  3,  3,  7,  7,  7,  7,  7,  7,  7,  7,  3,  3,  1,  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,  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,
     38     };
     39     oled_write_raw_P(raw_logo, sizeof(raw_logo));
     40 }
     41 
     42 
     43 // 32 * 18 Merge logos
     44 static const char PROGMEM merge_logo[] = {
     45     0xf8, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x0e,
     46     0x06, 0x04, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xf0, 0xc0,
     47     0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xc0,
     48     0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f,
     49     0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,
     50     0x01, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00
     51 };
     52 
     53 static void print_status_narrow(void) {
     54     oled_set_cursor(0,1);
     55     oled_write_raw_P(merge_logo, sizeof(merge_logo));
     56     oled_set_cursor(0,5);
     57     oled_write_P(PSTR("-----"), false);
     58     oled_set_cursor(0,6);
     59     oled_write_P(PSTR("LYR "), false);
     60     switch (get_highest_layer(layer_state)) {
     61         case 0:
     62             oled_write_P(PSTR("0"), false);
     63             break;
     64         case 1:
     65             oled_write_P(PSTR("1"), false);
     66             break;
     67         case 2:
     68             oled_write_P(PSTR("2"), false);
     69             break;
     70         case 3:
     71             oled_write_P(PSTR("3"), false);
     72             break;
     73         default:
     74             oled_write_ln_P(PSTR("Undef"), false);
     75     }
     76     led_t led_usb_state = host_keyboard_led_state();
     77     oled_write_ln_P(PSTR(" "), false);
     78     oled_write_P(PSTR("CAP "), false);
     79     oled_write_P(PSTR("."), led_usb_state.caps_lock);
     80     oled_write_P(PSTR("NUM "), false);
     81     oled_write_P(PSTR("."), led_usb_state.num_lock);
     82     oled_write_P(PSTR("SCR "), false);
     83     oled_write_P(PSTR("."), led_usb_state.scroll_lock);
     84     //oled_write_ln_P(PSTR(" "), false);
     85     oled_write_P(PSTR("-----"), false);
     86 
     87 #ifdef WPM_ENABLE
     88     // WPM counter Start
     89     oled_set_cursor(0,13);
     90     oled_write(" ", false);
     91     oled_write(get_u8_str(get_current_wpm(), '0'), false);
     92     oled_set_cursor(0,14);
     93     oled_write(" WPM ", false);
     94     // WPM counter End
     95 #endif
     96 }
     97 
     98 bool oled_task_kb(void) {
     99     if (!oled_task_user()) { return false; }
    100     if (is_keyboard_master()) {
    101         print_status_narrow();
    102         //render_logo();
    103     } else {
    104         render_logo();
    105         //print_status_narrow();
    106     }
    107     return false;
    108 }
    109 #endif