qmk_firmware

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

microdox.c (2947B)


      1 /*
      2 Copyright 2022 Cole Smith <cole@boadsource.xyz>
      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 #ifdef OLED_ENABLE
     19 #include "oled_driver.h"
     20 #include "bitwise.h"
     21 #include "action_layer.h"
     22 
     23 oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
     24   if (is_keyboard_master())
     25     return OLED_ROTATION_180;
     26   return rotation;
     27 }
     28 
     29 static void render_logo(void) {
     30   static const char PROGMEM qmk_logo[] = {
     31     0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
     32     0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
     33     0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
     34   };
     35   oled_write_P(qmk_logo, false);
     36 }
     37 static void render_status(void) {
     38    switch (get_highest_layer(layer_state)) {
     39     case 0:
     40       oled_write_P(PSTR("B R L A O\n"), false);
     41       oled_write_P(PSTR("^\n"), false);
     42       oled_write_P(PSTR("Layer: Base\n"), false);
     43       break;
     44     case 1:
     45       oled_write_P(PSTR("B R L A O\n"), false);
     46       oled_write_P(PSTR("  ^\n"), false);
     47       oled_write_P(PSTR("Layer: Raise\n"), false);
     48       break;
     49     case 2:
     50       oled_write_P(PSTR("B R L A O\n"), false);
     51       oled_write_P(PSTR("    ^\n"), false);
     52       oled_write_P(PSTR("Layer: Lower\n"), false);
     53       break;
     54     case 3:
     55       oled_write_P(PSTR("B R L A O\n"), false);
     56       oled_write_P(PSTR("      ^\n"), false);
     57       oled_write_P(PSTR("Layer: Adjust\n"), false);
     58       break;
     59     default:
     60       oled_write_P(PSTR("B R L A O"), false);
     61       oled_write_P(PSTR("        ^\n"), false);
     62       oled_write_P(PSTR("Layer: Other\n"), false);
     63   }
     64 }
     65 
     66 bool oled_task_kb(void) {
     67   if (!oled_task_user()) { return false; }
     68   if (is_keyboard_master()) {
     69     render_status();
     70   } else {
     71     render_logo();
     72     oled_scroll_left();
     73   }
     74   return false;
     75 }
     76 #endif
     77 
     78 #ifdef ENCODER_ENABLE
     79 #include "encoder.h"
     80 bool encoder_update_kb(uint8_t index, bool clockwise) {
     81   if (!encoder_update_user(index, clockwise)) { return false; }
     82   if (index == 0) {
     83     if (clockwise) {
     84       tap_code_delay(KC_VOLU, 10);
     85     } else {
     86       tap_code_delay(KC_VOLD, 10);  
     87     }
     88   } else {
     89     if (clockwise) {
     90       tap_code(KC_MNXT);
     91     } else {
     92       tap_code(KC_MPRV);
     93     }
     94   }
     95   return true;
     96 }
     97 #endif