diff options
Diffstat (limited to 'keyboards/dp60/keymaps/indicator/indicator.c')
-rw-r--r-- | keyboards/dp60/keymaps/indicator/indicator.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/keyboards/dp60/keymaps/indicator/indicator.c b/keyboards/dp60/keymaps/indicator/indicator.c new file mode 100644 index 000000000..a3a826e8a --- /dev/null +++ b/keyboards/dp60/keymaps/indicator/indicator.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /** | ||
2 | * indicator.c | ||
3 | * | ||
4 | Copyright 2020 astro <[email protected]> | ||
5 | This program is free software: you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation, either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
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 | 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 "dp60.h" | ||
18 | |||
19 | #include "rgblight_list.h" | ||
20 | #include "rgblight.h" | ||
21 | |||
22 | |||
23 | // caps led | ||
24 | const rgblight_segment_t PROGMEM dp60_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
25 | {18, 1, HSV_RED} | ||
26 | ); | ||
27 | |||
28 | // scroll led | ||
29 | const rgblight_segment_t PROGMEM dp60_scrolllock_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
30 | {19, 1, HSV_GREEN} | ||
31 | ); | ||
32 | |||
33 | // num led | ||
34 | const rgblight_segment_t PROGMEM dp60_numlock_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
35 | {20, 1, HSV_BLUE} | ||
36 | ); | ||
37 | |||
38 | // light 21 to 26 for layer 1-5 | ||
39 | const rgblight_segment_t PROGMEM dp60_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
40 | {21, 1, HSV_PURPLE} | ||
41 | ); | ||
42 | const rgblight_segment_t PROGMEM dp60_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
43 | {22, 1, HSV_CYAN} | ||
44 | ); | ||
45 | const rgblight_segment_t PROGMEM dp60_layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
46 | {23, 1, HSV_YELLOW} | ||
47 | ); | ||
48 | const rgblight_segment_t PROGMEM dp60_layer4_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
49 | {24, 1, HSV_PINK} | ||
50 | ); | ||
51 | const rgblight_segment_t PROGMEM dp60_layer5_layer[] = RGBLIGHT_LAYER_SEGMENTS( | ||
52 | {25, 1, HSV_ORANGE} | ||
53 | ); | ||
54 | |||
55 | // rgb light layers | ||
56 | const rgblight_segment_t* const PROGMEM dp60_rgb_layers[] = RGBLIGHT_LAYERS_LIST( | ||
57 | dp60_capslock_layer, | ||
58 | dp60_scrolllock_layer, | ||
59 | dp60_numlock_layer, | ||
60 | dp60_layer1_layer, | ||
61 | dp60_layer2_layer, | ||
62 | dp60_layer3_layer, | ||
63 | dp60_layer4_layer, | ||
64 | dp60_layer5_layer | ||
65 | ); | ||
66 | |||
67 | void keyboard_post_init_user(void) { | ||
68 | // Enable the LED layers | ||
69 | rgblight_layers = dp60_rgb_layers; | ||
70 | } | ||
71 | |||
72 | extern rgblight_config_t rgblight_config; | ||
73 | extern void rgblight_layers_write(void); | ||
74 | extern void indicator_write(LED_TYPE *start_led, uint8_t num_leds); | ||
75 | |||
76 | void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) | ||
77 | { | ||
78 | ws2812_setleds(start_led, RGBLED_NUM-RGB_INDICATOR_NUM); | ||
79 | |||
80 | indicator_write(start_led + (RGBLED_NUM - RGB_INDICATOR_NUM), RGB_INDICATOR_NUM); | ||
81 | } | ||
82 | |||
83 | bool led_update_kb(led_t led_state) { | ||
84 | bool res = led_update_user(led_state); | ||
85 | if (res) { | ||
86 | rgblight_set_layer_state(0, led_state.caps_lock); | ||
87 | rgblight_set_layer_state(1, led_state.scroll_lock); | ||
88 | rgblight_set_layer_state(2, led_state.num_lock); | ||
89 | } | ||
90 | return res; | ||
91 | } | ||
92 | |||
93 | layer_state_t layer_state_set_kb(layer_state_t state) { | ||
94 | state = layer_state_set_user(state); | ||
95 | rgblight_set_layer_state(3, layer_state_cmp(state, 1)); | ||
96 | rgblight_set_layer_state(4, layer_state_cmp(state, 2)); | ||
97 | rgblight_set_layer_state(5, layer_state_cmp(state, 3)); | ||
98 | rgblight_set_layer_state(6, layer_state_cmp(state, 4)); | ||
99 | rgblight_set_layer_state(7, layer_state_cmp(state, 5)); | ||
100 | return state; | ||
101 | } | ||