summaryrefslogtreecommitdiffstats
path: root/users/drashna/rgb/rgb_stuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/rgb/rgb_stuff.c')
-rw-r--r--users/drashna/rgb/rgb_stuff.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/users/drashna/rgb/rgb_stuff.c b/users/drashna/rgb/rgb_stuff.c
index e0422334aa..09071f7151 100644
--- a/users/drashna/rgb/rgb_stuff.c
+++ b/users/drashna/rgb/rgb_stuff.c
@@ -23,9 +23,29 @@ static bool is_enabled;
static bool is_rgblight_startup;
static HSV old_hsv;
static uint8_t old_mode;
-static uint16_t rgblight_startup_loop_timer;
+deferred_token rgb_startup_token;
# endif
+uint32_t rgb_startup_animation(uint32_t triger_time, void *cb_arg) {
+ if (is_rgblight_startup && is_keyboard_master()) {
+ static uint8_t counter = 0;
+ counter++;
+ rgblight_sethsv_noeeprom((counter + old_hsv.h) % 255, 255, 255);
+ if (counter >= 255) {
+ is_rgblight_startup = false;
+ if (userspace_config.rgb_layer_change) {
+ layer_state_set_rgb_light(layer_state);
+ } else {
+ rgblight_set_hsv_and_mode(old_hsv.h, old_hsv.s, old_hsv.v, old_mode);
+ }
+ if (!is_enabled) {
+ rgblight_disable_noeeprom();
+ }
+ }
+ }
+ return is_rgblight_startup ? 10 : 0;
+}
+
void keyboard_post_init_rgb_light(void) {
# if defined(RGBLIGHT_STARTUP_ANIMATION)
is_enabled = rgblight_is_enabled();
@@ -40,30 +60,8 @@ void keyboard_post_init_rgb_light(void) {
if (userspace_config.rgb_layer_change) {
layer_state_set_rgb_light(layer_state);
}
-}
+ rgb_startup_token = defer_exec(300, rgb_startup_animation, NULL);
-void matrix_scan_rgb_light(void) {
-# if defined(RGBLIGHT_STARTUP_ANIMATION)
- if (is_rgblight_startup && is_keyboard_master()) {
- if (sync_timer_elapsed(rgblight_startup_loop_timer) > 10) {
- static uint8_t counter;
- counter++;
- rgblight_sethsv_noeeprom((counter + old_hsv.h) % 255, 255, 255);
- rgblight_startup_loop_timer = sync_timer_read();
- if (counter == 255) {
- is_rgblight_startup = false;
- if (userspace_config.rgb_layer_change) {
- layer_state_set_rgb_light(layer_state);
- } else {
- rgblight_set_hsv_and_mode(old_hsv.h, old_hsv.s, old_hsv.v, old_mode);
- }
- if (!is_enabled) {
- rgblight_disable_noeeprom();
- }
- }
- }
- }
-# endif
}
layer_state_t layer_state_set_rgb_light(layer_state_t state) {