diff options
author | Drashna Jael're <drashna@live.com> | 2022-01-30 13:23:13 -0800 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2022-01-30 13:23:13 -0800 |
commit | b57f8a8b9fd50bdb39473e7730400e14b879da72 (patch) | |
tree | 430a140a24cf571b87423bdcd1fa5ad0a0461364 /users/drashna/rgb/rgb_stuff.c | |
parent | 1be1bebc043483c5a8fc77ed8b2705676a6cb05c (diff) | |
parent | 941b1d35b8e40a9c93301a1131ef3f3336fee0b5 (diff) | |
download | qmk_firmware-b57f8a8b9fd50bdb39473e7730400e14b879da72.tar.gz qmk_firmware-b57f8a8b9fd50bdb39473e7730400e14b879da72.zip |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'users/drashna/rgb/rgb_stuff.c')
-rw-r--r-- | users/drashna/rgb/rgb_stuff.c | 46 |
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) { |