qmk_firmware

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

magnum_ergo_1.c (2533B)


      1 /* Copyright 2023 Gondolindrim <gondolindrim@acheronproject.com>
      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 void keyoard_post_init_kb(void) {
     20     gpio_set_pin_output(LED_CAPS_LOCK_PIN);
     21     gpio_set_pin_output(LED_INDICATOR_1);
     22     gpio_set_pin_output(LED_INDICATOR_2);
     23     gpio_set_pin_output(LED_INDICATOR_3);
     24     gpio_set_pin_output(LED_INDICATOR_4);
     25     gpio_set_pin_output(LED_INDICATOR_5);
     26 #ifndef LED_CAPS_LOCK_PIN
     27     gpio_write_pin(LED_CAPS_LOCK_PIN, 0);
     28 #endif
     29 
     30 #ifndef LED_INDICATOR_1
     31     gpio_write_pin(LED_INDICATOR_1, 0);
     32 #endif
     33 
     34 #ifndef LED_INDICATOR_2
     35     gpio_write_pin(LED_INDICATOR_2, 0);
     36 #endif
     37 
     38 #ifndef LED_INDICATOR_3
     39     gpio_write_pin(LED_INDICATOR_3, 0);
     40 #endif
     41 
     42 #ifndef LED_INDICATOR_4
     43     gpio_write_pin(LED_INDICATOR_4, 0);
     44 #endif
     45 
     46 #ifndef LED_INDICATOR_5
     47     gpio_write_pin(LED_INDICATOR_5, 0);
     48 #endif
     49     keyboard_post_init_user();
     50 }
     51 
     52 layer_state_t layer_state_set_kb(layer_state_t state) {
     53         switch (get_highest_layer(state)) {
     54         case 1:
     55 #ifdef LED_INDICATOR_4
     56             gpio_write_pin(LED_INDICATOR_4, 1);
     57 #endif
     58 
     59 #ifdef LED_INDICATOR_5
     60             gpio_write_pin(LED_INDICATOR_5, 1);
     61 #endif
     62             break;
     63         case 2:
     64 #ifdef LED_INDICATOR_1
     65             gpio_write_pin(LED_INDICATOR_1, 1);
     66 #endif
     67 #ifdef LED_INDICATOR_2
     68             gpio_write_pin(LED_INDICATOR_2, 1);
     69 #endif
     70 #ifdef LED_INDICATOR_3
     71             gpio_write_pin(LED_INDICATOR_3, 1);
     72 #endif
     73             break;
     74         default:
     75 #ifdef LED_INDICATOR_1
     76             gpio_write_pin(LED_INDICATOR_1, 0);
     77 #endif
     78 #ifdef LED_INDICATOR_2
     79             gpio_write_pin(LED_INDICATOR_2, 0);
     80 #endif
     81 #ifdef LED_INDICATOR_3
     82             gpio_write_pin(LED_INDICATOR_3, 0);
     83 #endif
     84 #ifdef LED_INDICATOR_4
     85             gpio_write_pin(LED_INDICATOR_4, 0);
     86 #endif
     87 #ifdef LED_INDICATOR_5
     88             gpio_write_pin(LED_INDICATOR_5, 0);
     89 #endif
     90             break;
     91     }
     92     return layer_state_set_user(state);
     93 }