qmk_firmware

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

recon.c (7701B)


      1 /* Copyright 2024 XD Boards <copyright@xdboards.xyz>
      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 oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
     21    return OLED_ROTATION_180;
     22 }
     23 
     24 bool oled_task_kb(void) {
     25     if (!oled_task_user()) {
     26        return false;
     27     }
     28     if (is_keyboard_master()) {
     29         // Host Keyboard Layer Status
     30         oled_write_P(PSTR("Layer: "), false);
     31         switch (get_highest_layer(layer_state | default_layer_state)) {
     32             case 0:
     33                 oled_write_P(PSTR("QWERTY\n"), false);
     34                 break;
     35             case 1:
     36                 oled_write_P(PSTR("Symbols\n"), false);
     37                 break;
     38             case 2:
     39                 oled_write_P(PSTR("Numbers\n"), false);
     40                 break;
     41             case 3:
     42                 oled_write_P(PSTR("Function\n"), false);
     43                 break;
     44             case 4:
     45                 oled_write_P(PSTR("RGB\n"), false);
     46                 break;
     47             default:
     48                 oled_write_P(PSTR("Undefined\n"), false);
     49         }
     50         // Host Keyboard LED Status
     51         led_t led_usb_state = host_keyboard_led_state();
     52         oled_write_P(PSTR("CAPSLCK"), led_usb_state.caps_lock);
     53         oled_write_P(PSTR(" "), false);
     54         oled_write_P(PSTR("NUMLCK"), led_usb_state.num_lock);
     55         oled_write_P(PSTR(" "), false);
     56         oled_write_P(PSTR("SCRLCK"), led_usb_state.scroll_lock);
     57         oled_write_P(PSTR("\n"), false);
     58 
     59         oled_write_P(PSTR("\n"), false);
     60 
     61         static const char PROGMEM qmk_logo[] = {
     62             0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
     63             0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4,
     64             0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0x00
     65         };
     66 
     67         oled_write_P(qmk_logo, false);
     68 
     69     } else {
     70         // clang-format off
     71         static const char PROGMEM recon_logo[] = {
     72             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,254,254,254,  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,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     73             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,128,192,224,240,240,248,252,124,126, 62, 62, 31, 31, 31,  0,  0,  0,255,255,255,  0,  0, 31, 31, 31, 62, 62, 62,124,252,248,248,240,224,192,192,  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,
     74             0,  0,  0,  0,  0,  0,  0,  0,128,224,248,252,255,127, 31, 15,  7,  3,  1,  0,  0,  0,  0,128,192,224,224,240,240,240,115,115,115,240,240,224,224,192,192,128,  0,  0,  0,  0,  1,  3,  7, 15, 63,255,254,252,240,192,  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,
     75           192,192,192,192,192,192,192,204,207,207,207,207,193,192,192,192,192,  0,  0,224,248,254,255, 15,  7,  3,  1,  0,192,224,224,224,224,192,  0,  1,  1,  3,  7, 63,255,252,240,  0,  0,192,192,192,192,192,199,207,207,207,207,192,192,192,192,192,192,192,128,  0,254,254,254,254,254,  0,134,254,254,252,124, 48,  0,  0,254,254,254,254,254,252,134,230,222, 62,  0,224,248,252,252,254,  6,  2,  6, 14, 62,126,  0,224,248,252,254,254,  6,  6,254,254,252,248,240,  0,  6,238,254,126,254,254,252,240,224,134,254, 14,  6,  0,
     76             3,  3,  3,  3,  3,  3,  3, 51,243,243,243,243,131,  3,  3,  3,  3,  0,  0,  7, 31,127,255,240,224,192,128,  0,  1,  7,  7,  7,  7,  3,  0,128,128,192,224,252,255, 63, 15,  0,  0,  3,  3,  3,  3,  3,227,243,243,243,243,  3,  3,  3,  3,  3,  3,  3,  1, 64,127,127,127,127,127, 97,  3,127,127,127,126,120, 48,  0,127,127,127,127,127, 63, 97,103,119,124, 48, 15, 31, 63,127,127, 96, 64, 96, 96, 48, 24,  0, 15, 31, 63,127,127, 64, 64,127,127, 63, 63, 15,  0, 64,127,127, 96,  1,  7, 15, 63,127,127,127,  0,  0,  0,
     77             0,  0,  0,  0,  0,  0,  0,  0,  1,  7, 31, 63,255,254,248,240,224,192,128,  0,  0,  0,  0,  1,  3,  7,  7,  7, 15, 15,207,206,207, 15, 15,  7,  7,  3,  3,  1,  0,  0,  0,  0,128,192,224,248,252,255,127, 63, 15,  7,  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,
     78             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  3,  7, 15, 15, 31, 63, 62,126,124,124,248,248,248,  0,  0,  0,255,255,255,  0,  0,248,248,248,124,124,124, 62, 63, 31, 15, 15,  7,  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,
     79             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,127,127,127,  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,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
     80         };
     81         // clang-format on
     82         oled_write_raw_P(recon_logo, sizeof(recon_logo));
     83     }
     84     return false;
     85 }
     86 #endif
     87 #ifdef ENCODER_ENABLE
     88 bool encoder_update_kb(uint8_t index, bool clockwise) {
     89     if (!encoder_update_user(index, clockwise)) {
     90        return false;
     91     }
     92 
     93     if (index == 0) {
     94         // Volume control
     95         if (clockwise) {
     96             tap_code(KC_VOLU);
     97         } else {
     98             tap_code(KC_VOLD);
     99         }
    100     } else if (index == 1) {
    101        // Page up/Page down
    102         if (clockwise) {
    103 #ifdef MOUSEKEY_ENABLE
    104             tap_code(MS_WHLU);
    105 #else
    106             tap_code(KC_PGUP);
    107 #endif
    108         } else {
    109 #ifdef MOUSEKEY_ENABLE
    110             tap_code(MS_WHLD);
    111 #else
    112             tap_code(KC_PGDN);
    113 #endif
    114         }
    115     }
    116     return true;
    117 }
    118 #endif