qmk_firmware

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

um80.c (4986B)


      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 #ifndef WPM_ENABLE
     20 #    define get_current_wpm() 0
     21 #endif
     22 
     23 #ifdef OLED_ENABLE
     24 void suspend_power_down_kb(void) {
     25     oled_off();
     26     suspend_power_down_user();
     27 }
     28 
     29 oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
     30     if (is_keyboard_master()) {
     31         return OLED_ROTATION_90;
     32     }
     33 
     34     return rotation;
     35 }
     36 
     37 //UM-80 logo
     38 static void render_logo(void) {
     39     static const char PROGMEM raw_logo[] = {
     40         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,
     41         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,
     42         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,
     43         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,
     44         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,
     45         0,0,0,254,254,254,252,248,224,192,128,224,248,252,254,254,254,0,0,128,128,128,128,128,128,0,0,0,120,252,254,206,
     46         206,206,206,254,124,120,0,0,240,248,252,62,30,14,14,30,62,252,248,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
     47         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,
     48         255,255,255,255,127,63,15,0,0,0,0,0,0,0,0,0,15,63,63,124,112,112,112,112,124,63,63,15,0,0,0,127,127,127,0,1,7,15,
     49         15,7,1,0,127,127,127,0,0,3,3,3,3,3,3,1,0,30,63,127,123,113,113,113,123,127,63,30,0,0,15,31,63,124,120,112,112,120,
     50         124,63,31,15,0,0,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,
     51         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,
     52         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
     53     };
     54     oled_write_raw_P(raw_logo, sizeof(raw_logo));
     55 }
     56 
     57 
     58 // 32 * 18 Merge logo
     59 static const char PROGMEM merge_logo[] = {
     60     0xf8, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x0e,
     61     0x06, 0x04, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfc, 0xf8, 0xf0, 0xc0,
     62     0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xc0,
     63     0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x3f, 0x0f,
     64     0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,
     65     0x01, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00
     66 };
     67 
     68 static void print_status_narrow(void) {
     69     oled_set_cursor(0,1);
     70     oled_write_raw_P(merge_logo, sizeof(merge_logo));
     71     oled_set_cursor(0,5);
     72     oled_write_P(PSTR("-----"), false);
     73     oled_set_cursor(0,6);
     74     oled_write_P(PSTR("LYR "), false);
     75     switch (get_highest_layer(layer_state)) {
     76         case 0:
     77             oled_write_P(PSTR("0"), false);
     78             break;
     79         case 1:
     80             oled_write_P(PSTR("1"), false);
     81             break;
     82         case 2:
     83             oled_write_P(PSTR("2"), false);
     84             break;
     85         case 3:
     86             oled_write_P(PSTR("3"), false);
     87             break;
     88         default:
     89             oled_write_ln_P(PSTR("Undef"), false);
     90     }
     91     led_t led_usb_state = host_keyboard_led_state();
     92     oled_write_ln_P(PSTR(" "), false);
     93     oled_write_P(PSTR("CAP "), false);
     94     oled_write_P(PSTR("."), led_usb_state.caps_lock);
     95     oled_write_P(PSTR("NUM "), false);
     96     oled_write_P(PSTR("."), led_usb_state.num_lock);
     97     oled_write_P(PSTR("SCR "), false);
     98     oled_write_P(PSTR("."), led_usb_state.scroll_lock);
     99     //oled_write_ln_P(PSTR(" "), false);
    100     oled_write_P(PSTR("-----"), false);
    101 
    102     // WPM counter Start
    103     oled_set_cursor(0,13);
    104     oled_write(" ", false);
    105     oled_write(get_u8_str(get_current_wpm(), '0'), false);
    106     oled_set_cursor(0,14);
    107     oled_write(" WPM ", false);
    108     // WPM counter End
    109 }
    110 
    111 bool oled_task_kb(void) {
    112     if (!oled_task_user()) { return false; }
    113     if (is_keyboard_master()) {
    114         print_status_narrow();
    115         //render_logo();
    116     } else {
    117         render_logo();
    118         //print_status_narrow();
    119     }
    120     return false;
    121 }
    122 
    123 #endif