qmk_firmware

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

la_plus.c (3259B)


      1 /* Copyright 2021 Harrison Chan (Xelus)
      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 "la_plus.h"
     18 #include "print.h"
     19 
     20 #define _____ NO_LED
     21 
     22 keyboard_config_t keyboard_config;
     23 
     24 led_config_t g_led_config = { {
     25   // Key Matrix to LED Index
     26   { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
     27   { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
     28   { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
     29   { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ },
     30   { _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ }
     31 }, {
     32   // LED Index to Physical Position
     33     {  2, 38 },
     34     {  0, 31 },
     35     {  2, 24 },
     36     {  0, 17 },
     37     {  2, 10 },
     38     {  0, 4  },
     39     {  4, 1  },
     40     { 14, 1  },
     41     { 30, 1  },
     42     { 47, 1  },
     43     { 63, 1  },
     44     { 79, 1  },
     45     { 95, 1  },
     46     {111, 1  },
     47     {144, 1  },
     48     {159, 1  },
     49     {176, 1  },
     50     {192, 1  },
     51     {208, 1  },
     52     {224, 1  },
     53     {241, 1  },
     54     {250, 0  },
     55     {255, 4  },
     56     {253, 10 },
     57     {255, 17 },
     58     {253, 24 },
     59     {255, 31 },
     60     {253, 38 },
     61     {241, 64 },
     62     {165, 64 },
     63     { 90, 64 },
     64     { 14, 64 }
     65 }, {
     66   // LED Index to Flag
     67   8, 8, 8, 8, 8, 8, 8, 8,
     68   8, 8, 8, 8, 8, 8, 8, 8,
     69   8, 8, 8, 8, 8, 8, 8, 8,
     70   8, 8, 8, 8, 8, 8, 8, 8
     71 } };
     72 
     73 void keyboard_post_init_kb(void) {
     74     // Call the post init code.
     75     // debug_enable=true;
     76 
     77     keyboard_config.raw = eeconfig_read_kb();
     78     if (keyboard_config.startup_animation_dots) {
     79         rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_startup_animation_dots);
     80     } else {
     81         rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_startup_animation_solid);
     82     }
     83 
     84     keyboard_post_init_user();
     85 }
     86 
     87 void eeconfig_init_kb(void) {
     88 #ifdef STARTUP_ANIMATION_DOTS
     89     keyboard_config.startup_animation_dots = false;
     90 #else
     91     keyboard_config.startup_animation_dots = true;
     92 #endif
     93     eeconfig_update_kb(keyboard_config.raw);
     94     eeconfig_init_user();
     95 }
     96 
     97 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
     98     if (!process_record_user(keycode, record)) {
     99         return false;
    100     }
    101 
    102     if (keycode == STARTUP_ANIMATION_CONFIG && record->event.pressed) {
    103         keyboard_config.startup_animation_dots = !(keyboard_config.startup_animation_dots);
    104 #ifdef CONSOLE_ENABLE
    105         uprintf("keyboard_config startup_animation_dots: %b\n", keyboard_config.startup_animation_dots);
    106 #endif
    107         eeconfig_update_kb(keyboard_config.raw);
    108     }
    109 
    110     return true;
    111 }