qmk_firmware

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

meridian.c (2166B)


      1 /*
      2 Copyright 2020 Holten Campbell
      3 
      4 This program is free software: you can redistribute it and/or modify
      5 it under the terms of the GNU General Public License as published by
      6 the Free Software Foundation, either version 2 of the License, or
      7 (at your option) any later version.
      8 
      9 This program is distributed in the hope that it will be useful,
     10 but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 GNU General Public License for more details.
     13 
     14 You should have received a copy of the GNU General Public License
     15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16 */
     17 
     18 #include "quantum.h"
     19 
     20 //Initialize B12 for in-switch caps lock
     21 void keyboard_pre_init_kb(void){
     22     gpio_set_pin_output(B12);
     23     keyboard_pre_init_user();
     24 }
     25 
     26 //Initialize all RGB indicators to 'off'
     27 __attribute__((weak))
     28 void keyboard_post_init_user(void) {
     29     rgblight_setrgb_at(0, 0, 0, 0); // [..., 0] = top LED
     30     rgblight_setrgb_at(0, 0, 0, 1); // [..., 1] = middle LED
     31     rgblight_setrgb_at(0, 0, 0, 2); // [..., 2] = bottom LED
     32 }
     33 
     34 //Indicator light function
     35 bool led_update_kb(led_t led_state) {
     36     bool res = led_update_user(led_state);
     37     if (res) {
     38  //       gpio_write_pin(B12, !led_state.caps_lock);  //Un-comment this line to enable in-switch capslock indicator
     39     if (led_state.caps_lock) {
     40         rgblight_setrgb_at(0, 255, 0, 0); //green
     41     } else {
     42         rgblight_setrgb_at(0, 0, 0, 0);
     43     }
     44     if (led_state.num_lock) {
     45         rgblight_setrgb_at(0, 0, 255, 1); //blue
     46     } else {
     47         rgblight_setrgb_at(0, 0, 0, 1);
     48     }
     49    if (led_state.scroll_lock) {          
     50         rgblight_setrgb_at(255, 0, 0, 2); //red
     51     } else {
     52         rgblight_setrgb_at(0, 0, 0, 2);
     53     }
     54 }
     55     return res;
     56 }
     57 
     58 //Below is an exmaple of layer indication using one of the RGB indicatiors. As configured, uses the bottom indicator (2) to light up red when layer 1 is in use. 
     59 /*
     60 layer_state_t layer_state_set_kb(layer_state_t state) {
     61     if (get_highest_layer(state) == 1) {
     62         rgblight_setrgb_at(255, 0, 0, 2);
     63     } else {
     64         rgblight_setrgb_at(0, 0, 0, 2);
     65     }
     66     return state;
     67 }
     68 */