aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/rgb_stuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/rgb_stuff.c')
-rw-r--r--users/drashna/rgb_stuff.c147
1 files changed, 115 insertions, 32 deletions
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index af7190cc3..f2a9a47a9 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -1,5 +1,6 @@
1#include "drashna.h" 1#include "drashna.h"
2#include "rgb_stuff.h" 2#include "rgb_stuff.h"
3#include "eeprom.h"
3 4
4extern rgblight_config_t rgblight_config; 5extern rgblight_config_t rgblight_config;
5extern userspace_config_t userspace_config; 6extern userspace_config_t userspace_config;
@@ -22,25 +23,64 @@ uint8_t current_osm;
22void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) { 23void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) {
23 if (userspace_config.rgb_layer_change && biton32(layer_state) == 0) { 24 if (userspace_config.rgb_layer_change && biton32(layer_state) == 0) {
24 if (this_mod & MODS_SHIFT_MASK || this_led & (1<<USB_LED_CAPS_LOCK) || this_osm & MODS_SHIFT_MASK) { 25 if (this_mod & MODS_SHIFT_MASK || this_led & (1<<USB_LED_CAPS_LOCK) || this_osm & MODS_SHIFT_MASK) {
25 rgblight_sethsv_at(0, 255, 255, SHFT_LED1); 26 #ifdef SHFT_LED1
26 rgblight_sethsv_at(0, 255, 255, SHFT_LED2); 27 rgblight_sethsv_at(120, 255, 255, SHFT_LED1);
28 #endif // SHFT_LED1
29 #ifdef SHFT_LED2
30 rgblight_sethsv_at(120, 255, 255, SHFT_LED2);
31 #endif // SHFT_LED2
27 } else { 32 } else {
28 rgblight_sethsv_default_helper(SHFT_LED1); 33 #ifdef SHFT_LED1
29 rgblight_sethsv_default_helper(SHFT_LED2); 34 rgblight_sethsv_default_helper(SHFT_LED1);
35 #endif // SHFT_LED1
36 #ifdef SHFT_LED2
37 rgblight_sethsv_default_helper(SHFT_LED2);
38 #endif // SHFT_LED2
30 } 39 }
31 if (this_mod & MODS_CTRL_MASK || this_osm & MODS_CTRL_MASK) { 40 if (this_mod & MODS_CTRL_MASK || this_osm & MODS_CTRL_MASK) {
32 rgblight_sethsv_at(51, 255, 255, CTRL_LED1); 41 #ifdef CTRL_LED1
33 rgblight_sethsv_at(51, 255, 255, CTRL_LED2); 42 rgblight_sethsv_at(0, 255, 255, CTRL_LED1);
43 #endif // CTRL_LED1
44 #ifdef CTRL_LED2
45 rgblight_sethsv_at(0, 255, 255, CTRL_LED2);
46 #endif // CTRL_LED2
34 } else { 47 } else {
35 rgblight_sethsv_default_helper(CTRL_LED1); 48 #ifdef CTRL_LED1
36 rgblight_sethsv_default_helper(CTRL_LED2); 49 rgblight_sethsv_default_helper(CTRL_LED1);
50 #endif // CTRL_LED1
51 #ifdef CTRL_LED2
52 rgblight_sethsv_default_helper(CTRL_LED2);
53 #endif // CTRL_LED2
37 } 54 }
38 if (this_mod & MODS_GUI_MASK || this_osm & MODS_GUI_MASK) { 55 if (this_mod & MODS_GUI_MASK || this_osm & MODS_GUI_MASK) {
39 rgblight_sethsv_at(120, 255, 255, GUI_LED1); 56 #ifdef GUI_LED1
40 rgblight_sethsv_at(120, 255, 255, GUI_LED2); 57 rgblight_sethsv_at(51, 255, 255, GUI_LED1);
58 #endif // GUI_LED1
59 #ifdef GUI_LED2
60 rgblight_sethsv_at(51, 255, 255, GUI_LED2);
61 #endif // GUI_LED2
41 } else { 62 } else {
42 rgblight_sethsv_default_helper(GUI_LED1); 63 #ifdef GUI_LED1
43 rgblight_sethsv_default_helper(GUI_LED2); 64 rgblight_sethsv_default_helper(GUI_LED1);
65 #endif // GUI_LED1
66 #ifdef GUI_LED2
67 rgblight_sethsv_default_helper(GUI_LED2);
68 #endif // GUI_LED2
69 }
70 if (this_mod & MODS_ALT_MASK || this_osm & MODS_ALT_MASK) {
71 #ifdef ALT_LED1
72 rgblight_sethsv_at(240, 255, 255, ALT_LED1);
73 #endif // ALT_LED1
74 #ifdef GUI_LED2
75 rgblight_sethsv_at(240, 255, 255, ALT_LED2);
76 #endif // GUI_LED2
77 } else {
78 #ifdef GUI_LED1
79 rgblight_sethsv_default_helper(ALT_LED1);
80 #endif // GUI_LED1
81 #ifdef GUI_LED2
82 rgblight_sethsv_default_helper(ALT_LED2);
83 #endif // GUI_LED2
44 } 84 }
45 } 85 }
46} 86}
@@ -63,7 +103,48 @@ void matrix_scan_indicator(void) {
63static rgblight_fadeout lights[RGBLED_NUM]; 103static rgblight_fadeout lights[RGBLED_NUM];
64 104
65__attribute__ ((weak)) 105__attribute__ ((weak))
66bool indicator_is_this_led_used(uint8_t index) { return false; } 106bool rgblight_twinkle_is_led_used_keymap(uint8_t index) { return false; }
107
108bool rgblight_twinkle_is_led_used(uint8_t index) {
109 switch (index) {
110#ifdef INDICATOR_LIGHTS
111#ifdef SHFT_LED1
112 case SHFT_LED1:
113 return true;
114#endif //SHFT_LED1
115#ifdef SHFT_LED2
116 case SHFT_LED2:
117 return true;
118#endif //SHFT_LED2
119#ifdef CTRL_LED1
120 case CTRL_LED1:
121 return true;
122#endif //CTRL_LED1
123#ifdef CTRL_LED2
124 case CTRL_LED2:
125 return true;
126#endif //CTRL_LED2
127#ifdef GUI_LED1
128 case GUI_LED1:
129 return true;
130#endif //GUI_LED1
131#ifdef GUI_LED2
132 case GUI_LED2:
133 return true;
134#endif //GUI_LED2
135#ifdef ALT_LED1
136 case ALT_LED1:
137 return true;
138#endif //ALT_LED1
139#ifdef ALT_LED2
140 case ALT_LED2:
141 return true;
142#endif //ALT_LED2
143#endif //INDICATOR_LIGHTS
144 default:
145 return rgblight_twinkle_is_led_used_keymap(index);
146 }
147}
67 148
68void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive 149void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive
69 bool litup = false; 150 bool litup = false;
@@ -97,7 +178,7 @@ void start_rgb_light(void) {
97 uint8_t min_life = 0xFF; 178 uint8_t min_life = 0xFF;
98 uint8_t min_life_index = -1; 179 uint8_t min_life_index = -1;
99 for (uint8_t index = 0 ; index < RGBLED_NUM ; ++index ) { 180 for (uint8_t index = 0 ; index < RGBLED_NUM ; ++index ) {
100 if (indicator_is_this_led_used(index)) { continue; } 181 if (rgblight_twinkle_is_led_used(index)) { continue; }
101 if (lights[index].enabled) { 182 if (lights[index].enabled) {
102 if (min_life_index == -1 || 183 if (min_life_index == -1 ||
103 lights[index].life < min_life) 184 lights[index].life < min_life)
@@ -181,16 +262,16 @@ void matrix_init_rgb(void) {
181#endif 262#endif
182 263
183 if (userspace_config.rgb_layer_change) { 264 if (userspace_config.rgb_layer_change) {
184 uint8_t default_layer = eeconfig_read_default_layer();
185 rgblight_enable_noeeprom(); 265 rgblight_enable_noeeprom();
186 if (default_layer & (1UL << _COLEMAK)) { 266 switch (biton32(eeconfig_read_default_layer())) {
187 rgblight_sethsv_magenta(); 267 case _COLEMAK:
188 } else if (default_layer & (1UL << _DVORAK)) { 268 rgblight_sethsv_noeeprom_magenta(); break;
189 rgblight_sethsv_green(); 269 case _DVORAK:
190 } else if (default_layer & (1UL << _WORKMAN)) { 270 rgblight_sethsv_noeeprom_green(); break;
191 rgblight_sethsv_goldenrod(); 271 case _WORKMAN:
192 } else { 272 rgblight_sethsv_noeeprom_goldenrod(); break;
193 rgblight_sethsv_cyan(); 273 default:
274 rgblight_sethsv_noeeprom_cyan(); break;
194 } 275 }
195 } 276 }
196} 277}
@@ -209,7 +290,6 @@ void matrix_scan_rgb(void) {
209 290
210uint32_t layer_state_set_rgb(uint32_t state) { 291uint32_t layer_state_set_rgb(uint32_t state) {
211#ifdef RGBLIGHT_ENABLE 292#ifdef RGBLIGHT_ENABLE
212 uint8_t default_layer = eeconfig_read_default_layer();
213 if (userspace_config.rgb_layer_change) { 293 if (userspace_config.rgb_layer_change) {
214 switch (biton32(state)) { 294 switch (biton32(state)) {
215 case _MACROS: 295 case _MACROS:
@@ -241,14 +321,15 @@ uint32_t layer_state_set_rgb(uint32_t state) {
241 rgblight_mode_noeeprom(23); 321 rgblight_mode_noeeprom(23);
242 break; 322 break;
243 default: // for any other layers, or the default layer 323 default: // for any other layers, or the default layer
244 if (default_layer & (1UL << _COLEMAK)) { 324 switch (biton32(default_layer_state)) {
245 rgblight_sethsv_noeeprom_magenta(); 325 case _COLEMAK:
246 } else if (default_layer & (1UL << _DVORAK)) { 326 rgblight_sethsv_noeeprom_magenta(); break;
247 rgblight_sethsv_noeeprom_green(); 327 case _DVORAK:
248 } else if (default_layer & (1UL << _WORKMAN)) { 328 rgblight_sethsv_noeeprom_green(); break;
249 rgblight_sethsv_noeeprom_goldenrod(); 329 case _WORKMAN:
250 } else { 330 rgblight_sethsv_noeeprom_goldenrod(); break;
251 rgblight_sethsv_noeeprom_cyan(); 331 default:
332 rgblight_sethsv_noeeprom_cyan(); break;
252 } 333 }
253 biton32(state) == _MODS ? rgblight_mode_noeeprom(2) : rgblight_mode_noeeprom(1); // if _MODS layer is on, then breath to denote it 334 biton32(state) == _MODS ? rgblight_mode_noeeprom(2) : rgblight_mode_noeeprom(1); // if _MODS layer is on, then breath to denote it
254 break; 335 break;
@@ -259,3 +340,5 @@ uint32_t layer_state_set_rgb(uint32_t state) {
259 340
260 return state; 341 return state;
261} 342}
343
344