qmk_firmware

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

halfcliff.c (3326B)


      1 /* Copyright 2021 n2
      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 
     21 // Defines names for use in layer keycodes and the keymap
     22 enum layer_names {
     23     _DEFAULT = 0,
     24     _RAISE,
     25     _LOWER,
     26     _ADJUST
     27 /*    _FN */
     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     return rotation;
     35 }
     36 oled_rotation_t oled_init_kb(oled_rotation_t rotation) { return OLED_ROTATION_180; }
     37 
     38 bool oled_task_kb(void) {
     39     if (!oled_task_user()) {
     40         return false;
     41     }
     42   if (!is_keyboard_master()) {
     43     static const char PROGMEM qmk_logo[] = {
     44         0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
     45         0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
     46         0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
     47     };
     48     oled_write_P(qmk_logo, false);
     49   } else {
     50       // Host Keyboard Layer Status
     51       oled_write_P(PSTR("Layer: "), false);
     52       switch (get_highest_layer(layer_state)) {
     53           case _DEFAULT:
     54               oled_write_P(PSTR("DEFAULT\n"), false);
     55               break;
     56           case _RAISE:
     57               oled_write_P(PSTR("RAISE\n"), false);
     58               break;
     59           case _LOWER:
     60               oled_write_P(PSTR("LOWER\n"), false);
     61           break;
     62           case _ADJUST:
     63               oled_write_P(PSTR("ADJUST\n"), false);
     64           break;
     65           default:
     66               // Or use the write_ln shortcut over adding '\n' to the end of your string
     67           oled_write_ln_P(PSTR("Undefined"), false);
     68       };
     69       // Host Keyboard LED Status
     70       led_t led_state = host_keyboard_led_state();
     71       oled_write_P(led_state.num_lock ? PSTR("NUMLCK ") : PSTR("       "), false);
     72       oled_write_P(led_state.caps_lock ? PSTR("CAPLCK ") : PSTR("       "), false);
     73       oled_write_P(led_state.scroll_lock ? PSTR("SCRLCK\n") : PSTR("      \n"), false);
     74     }
     75     return false;
     76 }
     77 #endif
     78 
     79 #ifdef ENCODER_ENABLE
     80 bool encoder_update_kb(uint8_t index, bool clockwise) {
     81     if (!encoder_update_user(index, clockwise)) { return false; }
     82     if (index == 0) { /* Left side encoder */
     83         if (clockwise) {
     84             tap_code(MS_WHLU);
     85         } else {
     86             tap_code(MS_WHLD);
     87         }
     88     } else if (index == 1) { /* Right side encoder */
     89         if (clockwise) {
     90             tap_code(MS_WHLU);
     91         } else {
     92             tap_code(MS_WHLD);
     93         }
     94     }
     95     return true;
     96 }
     97 #endif