diff options
| -rw-r--r-- | quantum/rgb_matrix/animations/starlight_anim.h | 29 | ||||
| -rw-r--r-- | quantum/rgb_matrix/animations/starlight_dual_hue_anim.h | 31 | ||||
| -rw-r--r-- | quantum/rgb_matrix/animations/starlight_dual_sat_anim.h | 31 |
3 files changed, 56 insertions, 35 deletions
diff --git a/quantum/rgb_matrix/animations/starlight_anim.h b/quantum/rgb_matrix/animations/starlight_anim.h index 742e843b57..c4f943c5ce 100644 --- a/quantum/rgb_matrix/animations/starlight_anim.h +++ b/quantum/rgb_matrix/animations/starlight_anim.h | |||
| @@ -2,7 +2,9 @@ | |||
| 2 | RGB_MATRIX_EFFECT(STARLIGHT) | 2 | RGB_MATRIX_EFFECT(STARLIGHT) |
| 3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | void set_starlight_color(uint8_t i, effect_params_t* params) { | 5 | static void set_starlight_color(uint8_t i, effect_params_t* params) { |
| 6 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; | ||
| 7 | |||
| 6 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); | 8 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); |
| 7 | hsv_t hsv = rgb_matrix_config.hsv; | 9 | hsv_t hsv = rgb_matrix_config.hsv; |
| 8 | hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); | 10 | hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); |
| @@ -11,21 +13,26 @@ void set_starlight_color(uint8_t i, effect_params_t* params) { | |||
| 11 | } | 13 | } |
| 12 | 14 | ||
| 13 | bool STARLIGHT(effect_params_t* params) { | 15 | bool STARLIGHT(effect_params_t* params) { |
| 14 | if (!params->init) { | 16 | static uint16_t index = RGB_MATRIX_LED_COUNT + 1; |
| 15 | if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0) { | 17 | |
| 16 | uint8_t rand_led = random8_max(RGB_MATRIX_LED_COUNT); | 18 | // Periodic trigger for LED change |
| 17 | set_starlight_color(rand_led, params); | 19 | if ((params->iter == 0) && (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0)) { |
| 18 | } | 20 | index = random8_max(RGB_MATRIX_LED_COUNT); |
| 19 | return false; | ||
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | 23 | RGB_MATRIX_USE_LIMITS(led_min, led_max); |
| 23 | for (uint8_t i = led_min; i < led_max; i++) { | 24 | if (params->init) { |
| 24 | RGB_MATRIX_TEST_LED_FLAGS(); | 25 | for (uint8_t i = led_min; i < led_max; i++) { |
| 25 | set_starlight_color(i, params); | 26 | set_starlight_color(i, params); |
| 27 | } | ||
| 28 | } | ||
| 29 | // Change LED once and set index out of range till next trigger | ||
| 30 | else if (led_min <= index && index < led_max) { | ||
| 31 | set_starlight_color(index, params); | ||
| 32 | index = RGB_MATRIX_LED_COUNT + 1; | ||
| 26 | } | 33 | } |
| 27 | return rgb_matrix_check_finished_leds(led_max); | 34 | return rgb_matrix_check_finished_leds(led_max); |
| 28 | } | 35 | } |
| 29 | 36 | ||
| 30 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 37 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 31 | #endif // ENABLE_RGB_MATRIX_STARLIGHT \ No newline at end of file | 38 | #endif // ENABLE_RGB_MATRIX_STARLIGHT |
diff --git a/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h b/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h index 50ce5d6ab4..276b8c3fdf 100644 --- a/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h +++ b/quantum/rgb_matrix/animations/starlight_dual_hue_anim.h | |||
| @@ -2,31 +2,38 @@ | |||
| 2 | RGB_MATRIX_EFFECT(STARLIGHT_DUAL_HUE) | 2 | RGB_MATRIX_EFFECT(STARLIGHT_DUAL_HUE) |
| 3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | void set_starlight_dual_hue_color(uint8_t i, effect_params_t* params) { | 5 | static void set_starlight_dual_hue_color(uint8_t i, effect_params_t* params) { |
| 6 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; | ||
| 7 | |||
| 6 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); | 8 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); |
| 7 | hsv_t hsv = rgb_matrix_config.hsv; | 9 | hsv_t hsv = rgb_matrix_config.hsv; |
| 8 | hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); | 10 | hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); |
| 9 | hsv.h = hsv.h + random8_max((30 + 1 - -30) + -30); | 11 | hsv.h = hsv.h + random8_max(31); |
| 10 | rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); | 12 | rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); |
| 11 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 13 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
| 12 | } | 14 | } |
| 13 | 15 | ||
| 14 | bool STARLIGHT_DUAL_HUE(effect_params_t* params) { | 16 | bool STARLIGHT_DUAL_HUE(effect_params_t* params) { |
| 15 | if (!params->init) { | 17 | static uint16_t index = RGB_MATRIX_LED_COUNT + 1; |
| 16 | if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0) { | 18 | |
| 17 | uint8_t rand_led = random8_max(RGB_MATRIX_LED_COUNT); | 19 | // Periodic trigger for LED change |
| 18 | set_starlight_dual_hue_color(rand_led, params); | 20 | if ((params->iter == 0) && (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0)) { |
| 19 | } | 21 | index = random8_max(RGB_MATRIX_LED_COUNT); |
| 20 | return false; | ||
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | 24 | RGB_MATRIX_USE_LIMITS(led_min, led_max); |
| 24 | for (uint8_t i = led_min; i < led_max; i++) { | 25 | if (params->init) { |
| 25 | RGB_MATRIX_TEST_LED_FLAGS(); | 26 | for (uint8_t i = led_min; i < led_max; i++) { |
| 26 | set_starlight_dual_hue_color(i, params); | 27 | set_starlight_dual_hue_color(i, params); |
| 28 | } | ||
| 29 | } | ||
| 30 | // Change LED once and set index out of range till next trigger | ||
| 31 | else if (led_min <= index && index < led_max) { | ||
| 32 | set_starlight_dual_hue_color(index, params); | ||
| 33 | index = RGB_MATRIX_LED_COUNT + 1; | ||
| 27 | } | 34 | } |
| 28 | return rgb_matrix_check_finished_leds(led_max); | 35 | return rgb_matrix_check_finished_leds(led_max); |
| 29 | } | 36 | } |
| 30 | 37 | ||
| 31 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 38 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 32 | #endif // ENABLE_RGB_MATRIX_STARLIGHT_DUAL_HUE \ No newline at end of file | 39 | #endif // ENABLE_RGB_MATRIX_STARLIGHT_DUAL_HUE |
diff --git a/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h b/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h index 6def4eea09..e063658982 100644 --- a/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h +++ b/quantum/rgb_matrix/animations/starlight_dual_sat_anim.h | |||
| @@ -2,31 +2,38 @@ | |||
| 2 | RGB_MATRIX_EFFECT(STARLIGHT_DUAL_SAT) | 2 | RGB_MATRIX_EFFECT(STARLIGHT_DUAL_SAT) |
| 3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 3 | # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 4 | 4 | ||
| 5 | void set_starlight_dual_sat_color(uint8_t i, effect_params_t* params) { | 5 | static void set_starlight_dual_sat_color(uint8_t i, effect_params_t* params) { |
| 6 | if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; | ||
| 7 | |||
| 6 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); | 8 | uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); |
| 7 | hsv_t hsv = rgb_matrix_config.hsv; | 9 | hsv_t hsv = rgb_matrix_config.hsv; |
| 8 | hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); | 10 | hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); |
| 9 | hsv.s = hsv.s + random8_max((30 + 1 - -30) + -30); | 11 | hsv.s = hsv.s + random8_max(31); |
| 10 | rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); | 12 | rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); |
| 11 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); | 13 | rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); |
| 12 | } | 14 | } |
| 13 | 15 | ||
| 14 | bool STARLIGHT_DUAL_SAT(effect_params_t* params) { | 16 | bool STARLIGHT_DUAL_SAT(effect_params_t* params) { |
| 15 | if (!params->init) { | 17 | static uint16_t index = RGB_MATRIX_LED_COUNT + 1; |
| 16 | if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0) { | 18 | |
| 17 | uint8_t rand_led = random8_max(RGB_MATRIX_LED_COUNT); | 19 | // Periodic trigger for LED change |
| 18 | set_starlight_dual_sat_color(rand_led, params); | 20 | if ((params->iter == 0) && (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 5)) % 5 == 0)) { |
| 19 | } | 21 | index = random8_max(RGB_MATRIX_LED_COUNT); |
| 20 | return false; | ||
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | RGB_MATRIX_USE_LIMITS(led_min, led_max); | 24 | RGB_MATRIX_USE_LIMITS(led_min, led_max); |
| 24 | for (uint8_t i = led_min; i < led_max; i++) { | 25 | if (params->init) { |
| 25 | RGB_MATRIX_TEST_LED_FLAGS(); | 26 | for (uint8_t i = led_min; i < led_max; i++) { |
| 26 | set_starlight_dual_sat_color(i, params); | 27 | set_starlight_dual_sat_color(i, params); |
| 28 | } | ||
| 29 | } | ||
| 30 | // Change LED once and set index out of range till next trigger | ||
| 31 | else if (led_min <= index && index < led_max) { | ||
| 32 | set_starlight_dual_sat_color(index, params); | ||
| 33 | index = RGB_MATRIX_LED_COUNT + 1; | ||
| 27 | } | 34 | } |
| 28 | return rgb_matrix_check_finished_leds(led_max); | 35 | return rgb_matrix_check_finished_leds(led_max); |
| 29 | } | 36 | } |
| 30 | 37 | ||
| 31 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS | 38 | # endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS |
| 32 | #endif // ENABLE_RGB_MATRIX_STARLIGHT_DUAL_SAT \ No newline at end of file | 39 | #endif // ENABLE_RGB_MATRIX_STARLIGHT_DUAL_SAT |
