hbcp.c (2302B)
1 /* Copyright 2019 Josh Hinnebusch 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 #include "quantum.h" 17 18 // Indicator color definitions 19 #ifndef HSV_CAPS 20 #define HSV_CAPS 0, 0, 120 // Define caps lock color (H, S, V) 21 #endif 22 23 #ifndef HSV_NLCK 24 #define HSV_NLCK 0, 0, 120 // Define num lock color (H, S, V) 25 #endif 26 27 #ifndef HSV_SCRL 28 #define HSV_SCRL 0, 0, 120 // Define scroll lock color (H, S, V) 29 #endif 30 31 #ifndef HSV_BLACK 32 #define HSV_BLACK 0, 0, 0 // Define 'black' color, more like 'LED off' (H, S, V) 33 #endif 34 35 // #define HSV_custom_color H, S, V 36 37 #ifdef RGBLIGHT_ENABLE 38 39 bool led_update_kb(led_t led_state) { 40 bool res = led_update_user(led_state); 41 if (res) { 42 if (led_state.caps_lock) { 43 rgblight_sethsv_at(HSV_CAPS, 0); 44 } else { 45 rgblight_sethsv_at(HSV_BLACK, 0); 46 } 47 if (led_state.num_lock) { 48 rgblight_sethsv_at(HSV_NLCK, 1); 49 } else { 50 rgblight_sethsv_at(HSV_BLACK, 1); 51 } 52 if (led_state.scroll_lock) { 53 rgblight_sethsv_at(HSV_SCRL, 2); 54 } else { 55 rgblight_sethsv_at(HSV_BLACK, 2); 56 } 57 } 58 return false; 59 } 60 61 __attribute__ ((weak)) 62 void keyboard_post_init_user(void) { 63 rgblight_set_effect_range(3, RGBLIGHT_LED_COUNT-3); 64 led_t led_state = { 65 .caps_lock = true, 66 .num_lock = true, 67 .scroll_lock = true 68 }; 69 led_update_kb(led_state); 70 wait_ms(300); 71 led_update_kb((led_t){0}); 72 } 73 74 __attribute__ ((weak)) 75 void hbcp_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) { 76 for (uint8_t i = start; i < end; i++) { 77 rgblight_sethsv_at(hue, sat, val, i); 78 } 79 } 80 81 #endif