qmk_firmware

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

link.c (2477B)


      1 // Copyright 2025 Andrew Kannan (awkannan)
      2 // SPDX-License-Identifier: GPL-2.0-or-later
      3 
      4 #include "quantum.h"
      5 
      6 #ifdef OLED_ENABLE
      7 oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
      8     if (is_keyboard_master()) {
      9         return OLED_ROTATION_0;
     10     } else {
     11         return OLED_ROTATION_90;
     12     }
     13     return rotation;
     14 }
     15 
     16 static void render_logo(void) {
     17     static const char PROGMEM qmk_logo[] = {
     18         0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
     19         0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
     20         0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0
     21     };
     22     oled_write_P(qmk_logo, false);
     23 }
     24 
     25 void print_status_narrow(void) {
     26     oled_write_P(PSTR("\n\n"), false);
     27     switch (get_highest_layer(layer_state)) {
     28         case 0:
     29             oled_write_ln_P(PSTR("Qwrt"), false);
     30             break;
     31         case 1:
     32             oled_write_ln_P(PSTR("Clmk"), false);
     33             break;
     34         default:
     35             oled_write_P(PSTR("Mod\n"), false);
     36             break;
     37     }
     38     oled_write_P(PSTR("\n\n"), false);
     39     oled_write_ln_P(PSTR("LAYER"), false);
     40     switch (get_highest_layer(layer_state)) {
     41         case 0:
     42         case 1:
     43             oled_write_P(PSTR("Base\n"), false);
     44             break;
     45         case 2:
     46             oled_write_P(PSTR("Raise"), false);
     47             break;
     48         case 3:
     49             oled_write_P(PSTR("Lower"), false);
     50             break;
     51         default:
     52             oled_write_ln_P(PSTR("Undef"), false);
     53     }
     54     oled_write_P(PSTR("\n\n"), false);
     55     led_t led_usb_state = host_keyboard_led_state();
     56     oled_write_ln_P(PSTR("CPSLK"), led_usb_state.caps_lock);
     57 }
     58 
     59 bool oled_task_kb(void) {
     60     if (!oled_task_user()) {
     61         return false;
     62     }
     63     if (is_keyboard_master()) {
     64         print_status_narrow();
     65     } else {
     66         render_logo();
     67     }
     68     return true;
     69 }
     70 
     71 #endif
     72 
     73 #ifdef ENCODER_ENABLE
     74 bool encoder_update_kb(uint8_t index, bool clockwise) {
     75     if (!encoder_update_user(index, clockwise)) {
     76         return false;
     77     }
     78     if (index == 0) {
     79         if (clockwise) {
     80             tap_code(KC_VOLU);
     81         } else {
     82             tap_code(KC_VOLD);
     83         }
     84     } else if (index == 1) {
     85         if (clockwise) {
     86             tap_code(KC_PGDN);
     87         } else {
     88             tap_code(KC_PGUP);
     89         }
     90     }
     91     return true;
     92 }
     93 #endif