summaryrefslogtreecommitdiffstats
path: root/users/drashna/rgb
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2022-01-30 13:20:33 -0800
committerGitHub <noreply@github.com>2022-01-30 13:20:33 -0800
commit941b1d35b8e40a9c93301a1131ef3f3336fee0b5 (patch)
tree54c8d1ec131d5c8a6e0dd89364a9840b3925fcdd /users/drashna/rgb
parent3555ee0555c8a9ff8aea2a101ae02a72b0e76076 (diff)
[Keymap] Add oled improvements and cnano keymap for drashna (#16133)
Diffstat (limited to 'users/drashna/rgb')
-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) {