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.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c
index b67f707b6..c8b2f4c72 100644
--- a/users/drashna/rgb_stuff.c
+++ b/users/drashna/rgb_stuff.c
@@ -14,15 +14,17 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#include "drashna.h" 17#ifdef RGBLIGHT_ENABLE
18#include "rgb_stuff.h" 18
19#include "eeprom.h" 19# include "drashna.h"
20# include "rgb_stuff.h"
21# include "eeprom.h"
20 22
21bool has_initialized; 23bool has_initialized;
22 24
23void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); } 25void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); }
24 26
25#ifdef RGBLIGHT_TWINKLE 27# ifdef RGBLIGHT_TWINKLE
26static rgblight_fadeout lights[RGBLED_NUM]; 28static rgblight_fadeout lights[RGBLED_NUM];
27 29
28/* Handler for fading/twinkling effect */ 30/* Handler for fading/twinkling effect */
@@ -91,7 +93,7 @@ void start_rgb_light(void) {
91 93
92 rgblight_sethsv_at(light->hue, 255, light->life, light_index); 94 rgblight_sethsv_at(light->hue, 255, light->life, light_index);
93} 95}
94#endif 96# endif
95 97
96bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) { 98bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
97 uint16_t temp_keycode = keycode; 99 uint16_t temp_keycode = keycode;
@@ -101,7 +103,7 @@ bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
101 } 103 }
102 104
103 switch (temp_keycode) { 105 switch (temp_keycode) {
104#ifdef RGBLIGHT_TWINKLE 106# ifdef RGBLIGHT_TWINKLE
105 case KC_A ... KC_SLASH: 107 case KC_A ... KC_SLASH:
106 case KC_F1 ... KC_F12: 108 case KC_F1 ... KC_F12:
107 case KC_INSERT ... KC_UP: 109 case KC_INSERT ... KC_UP:
@@ -112,20 +114,20 @@ bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
112 start_rgb_light(); 114 start_rgb_light();
113 } 115 }
114 break; 116 break;
115#endif // RGBLIGHT_TWINKLE 117# endif // RGBLIGHT_TWINKLE
116 } 118 }
117 return true; 119 return true;
118} 120}
119 121
120#if defined(RGBLIGHT_STARTUP_ANIMATION) 122# if defined(RGBLIGHT_STARTUP_ANIMATION)
121static bool is_enabled; 123static bool is_enabled;
122static bool is_rgblight_startup; 124static bool is_rgblight_startup;
123static uint8_t old_hue; 125static uint8_t old_hue;
124static uint16_t rgblight_startup_loop_timer; 126static uint16_t rgblight_startup_loop_timer;
125#endif 127# endif
126 128
127void keyboard_post_init_rgb_light(void) { 129void keyboard_post_init_rgb_light(void) {
128#if defined(RGBLIGHT_STARTUP_ANIMATION) 130# if defined(RGBLIGHT_STARTUP_ANIMATION)
129 is_enabled = rgblight_is_enabled(); 131 is_enabled = rgblight_is_enabled();
130 if (userspace_config.rgb_layer_change) { 132 if (userspace_config.rgb_layer_change) {
131 rgblight_enable_noeeprom(); 133 rgblight_enable_noeeprom();
@@ -136,7 +138,7 @@ void keyboard_post_init_rgb_light(void) {
136 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); 138 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
137 is_rgblight_startup = true; 139 is_rgblight_startup = true;
138 } 140 }
139#endif 141# endif
140 layer_state_set_rgb_light(layer_state); 142 layer_state_set_rgb_light(layer_state);
141} 143}
142 144
@@ -145,7 +147,7 @@ void matrix_scan_rgb_light(void) {
145 scan_rgblight_fadeout(); 147 scan_rgblight_fadeout();
146# endif // RGBLIGHT_ENABLE 148# endif // RGBLIGHT_ENABLE
147 149
148#if defined(RGBLIGHT_STARTUP_ANIMATION) 150# if defined(RGBLIGHT_STARTUP_ANIMATION)
149 if (is_rgblight_startup && is_keyboard_master()) { 151 if (is_rgblight_startup && is_keyboard_master()) {
150 if (timer_elapsed(rgblight_startup_loop_timer) > 10) { 152 if (timer_elapsed(rgblight_startup_loop_timer) > 10) {
151 static uint8_t counter; 153 static uint8_t counter;
@@ -163,7 +165,7 @@ void matrix_scan_rgb_light(void) {
163 } 165 }
164 } 166 }
165 } 167 }
166#endif 168# endif
167} 169}
168 170
169void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) { 171void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
@@ -173,16 +175,16 @@ void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mo
173} 175}
174 176
175layer_state_t layer_state_set_rgb_light(layer_state_t state) { 177layer_state_t layer_state_set_rgb_light(layer_state_t state) {
176#ifdef RGBLIGHT_ENABLE 178# ifdef RGBLIGHT_ENABLE
177 if (userspace_config.rgb_layer_change) { 179 if (userspace_config.rgb_layer_change) {
178 uint8_t mode = layer_state_cmp(state,_MODS) ? RGBLIGHT_MODE_BREATHING : RGBLIGHT_MODE_STATIC_LIGHT; 180 uint8_t mode = layer_state_cmp(state, _MODS) ? RGBLIGHT_MODE_BREATHING : RGBLIGHT_MODE_STATIC_LIGHT;
179 switch (get_highest_layer(state|default_layer_state)) { 181 switch (get_highest_layer(state | default_layer_state)) {
180 case _MACROS: 182 case _MACROS:
181# ifdef RGBLIGHT_EFFECT_TWINKLE 183# ifdef RGBLIGHT_EFFECT_TWINKLE
182 rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_TWINKLE + 5); 184 rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_TWINKLE + 5);
183# else 185# else
184 rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3); 186 rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3);
185# endif 187# endif
186 break; 188 break;
187 case _MEDIA: 189 case _MEDIA:
188 rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1); 190 rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1);
@@ -228,7 +230,9 @@ layer_state_t layer_state_set_rgb_light(layer_state_t state) {
228 break; 230 break;
229 } 231 }
230 } 232 }
231#endif // RGBLIGHT_ENABLE 233# endif // RGBLIGHT_ENABLE
232 234
233 return state; 235 return state;
234} 236}
237
238#endif