rev_b.c (1776B)
1 /* 2 Copyright 2022 Stefan Sundin "4pplet" <4pplet@protonmail.com> 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 #include "rev_b.h" 18 19 void keyboard_pre_init_kb(void) { 20 gpio_set_pin_output(LAYER_1); 21 gpio_set_pin_output(LAYER_2); 22 gpio_set_pin_output(LAYER_3); 23 gpio_set_pin_output(LAYER_4); 24 gpio_set_pin_output(LAYER_5); 25 keyboard_pre_init_user(); 26 } 27 28 layer_state_t layer_state_set_kb(layer_state_t state) { 29 state = layer_state_set_user(state); 30 setLayerLed(state); 31 return state; 32 } 33 /* Set indicator leds to indicate which layer is active */ 34 void setLayerLed(layer_state_t state){ 35 gpio_write_pin_low(LAYER_1); 36 gpio_write_pin_low(LAYER_2); 37 gpio_write_pin_low(LAYER_3); 38 gpio_write_pin_low(LAYER_4); 39 gpio_write_pin_low(LAYER_5); 40 switch (get_highest_layer(state)) { 41 case 0: 42 gpio_write_pin_high(LAYER_1); 43 break; 44 case 1: 45 gpio_write_pin_high(LAYER_2); 46 break; 47 case 2: 48 gpio_write_pin_high(LAYER_3); 49 break; 50 case 3: 51 gpio_write_pin_high(LAYER_4); 52 break; 53 case 4: 54 gpio_write_pin_high(LAYER_5); 55 break; 56 } 57 } 58