aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dp60/keymaps/indicator/indicator.c
diff options
context:
space:
mode:
authorAkshay <[email protected]>2022-04-10 12:13:40 +0100
committerAkshay <[email protected]>2022-04-10 12:13:40 +0100
commitdc90387ce7d8ba7b607d9c48540bf6d8b560f14d (patch)
tree4ccb8fa5886b66fa9d480edef74236c27f035e16 /keyboards/dp60/keymaps/indicator/indicator.c
Diffstat (limited to 'keyboards/dp60/keymaps/indicator/indicator.c')
-rw-r--r--keyboards/dp60/keymaps/indicator/indicator.c101
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
24const rgblight_segment_t PROGMEM dp60_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
25 {18, 1, HSV_RED}
26);
27
28// scroll led
29const rgblight_segment_t PROGMEM dp60_scrolllock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
30 {19, 1, HSV_GREEN}
31);
32
33// num led
34const 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
39const rgblight_segment_t PROGMEM dp60_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(
40 {21, 1, HSV_PURPLE}
41);
42const rgblight_segment_t PROGMEM dp60_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(
43 {22, 1, HSV_CYAN}
44);
45const rgblight_segment_t PROGMEM dp60_layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS(
46 {23, 1, HSV_YELLOW}
47);
48const rgblight_segment_t PROGMEM dp60_layer4_layer[] = RGBLIGHT_LAYER_SEGMENTS(
49 {24, 1, HSV_PINK}
50);
51const rgblight_segment_t PROGMEM dp60_layer5_layer[] = RGBLIGHT_LAYER_SEGMENTS(
52 {25, 1, HSV_ORANGE}
53);
54
55// rgb light layers
56const 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
67void keyboard_post_init_user(void) {
68 // Enable the LED layers
69 rgblight_layers = dp60_rgb_layers;
70}
71
72extern rgblight_config_t rgblight_config;
73extern void rgblight_layers_write(void);
74extern void indicator_write(LED_TYPE *start_led, uint8_t num_leds);
75
76void 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
83bool 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
93layer_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}