From adac1eef5324bab2b9a30988ad58944b2a04e7da Mon Sep 17 00:00:00 2001 From: hbbit-dev Date: Wed, 17 Jul 2024 18:09:11 -0700 Subject: [PATCH 1/6] feat: starlight smooth animation --- .../animations/rgb_matrix_effects.inc | 1 + .../animations/starlight_smooth_anim.h | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 quantum/rgb_matrix/animations/starlight_smooth_anim.h diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc index a02238a2d1a..3f3499fa94e 100644 --- a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc +++ b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc @@ -42,4 +42,5 @@ #include "starlight_anim.h" #include "starlight_dual_sat_anim.h" #include "starlight_dual_hue_anim.h" +#include "starlight_smooth_anim.h" #include "riverflow_anim.h" \ No newline at end of file diff --git a/quantum/rgb_matrix/animations/starlight_smooth_anim.h b/quantum/rgb_matrix/animations/starlight_smooth_anim.h new file mode 100644 index 00000000000..81775214ade --- /dev/null +++ b/quantum/rgb_matrix/animations/starlight_smooth_anim.h @@ -0,0 +1,36 @@ +#ifdef ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH +RGB_MATRIX_EFFECT(STAR_LIGHT_SMOOTH) +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS + +bool STAR_LIGHT_SMOOTH(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + // initialize static array for random offsets + static uint16_t time_offsets[RGB_MATRIX_LED_COUNT] = {0}; + static bool initialized = false; + + // initialize random offsets + if (!initialized) { + for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { + time_offsets[i] = rand() % 65500; + } + initialized = true; + } + + for (uint8_t i = led_min; i < led_max; i++) { + HSV hsv = rgb_matrix_config.hsv; + + // adjustable time calculation + uint16_t time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16); + hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); + + RGB rgb = rgb_matrix_hsv_to_rgb(hsv); + RGB_MATRIX_TEST_LED_FLAGS(); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + + return rgb_matrix_check_finished_leds(led_max); +} + +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH From 5319700afd0c362d3f562da1173b64b185456cd3 Mon Sep 17 00:00:00 2001 From: hbbit-dev Date: Wed, 17 Jul 2024 18:21:53 -0700 Subject: [PATCH 2/6] removed comments, clang-format, updated docs --- docs/features/rgb_matrix.md | 1 + quantum/rgb_matrix/animations/starlight_smooth_anim.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/features/rgb_matrix.md b/docs/features/rgb_matrix.md index aef766ebd24..230eff7a36d 100644 --- a/docs/features/rgb_matrix.md +++ b/docs/features/rgb_matrix.md @@ -720,6 +720,7 @@ You can enable a single effect by defining `ENABLE_[EFFECT_NAME]` in your `confi |`#define ENABLE_RGB_MATRIX_STARLIGHT` |Enables `RGB_MATRIX_STARLIGHT` | |`#define ENABLE_RGB_MATRIX_STARLIGHT_DUAL_HUE` |Enables `RGB_MATRIX_STARLIGHT_DUAL_HUE` | |`#define ENABLE_RGB_MATRIX_STARLIGHT_DUAL_SAT` |Enables `RGB_MATRIX_STARLIGHT_DUAL_SAT` | +|`#define ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH` |Enables `RGB_MATRIX_STARLIGHT_SMOOTH` | |`#define ENABLE_RGB_MATRIX_RIVERFLOW` |Enables `RGB_MATRIX_RIVERFLOW` | |Framebuffer Defines |Description | diff --git a/quantum/rgb_matrix/animations/starlight_smooth_anim.h b/quantum/rgb_matrix/animations/starlight_smooth_anim.h index 81775214ade..5543bfc79d8 100644 --- a/quantum/rgb_matrix/animations/starlight_smooth_anim.h +++ b/quantum/rgb_matrix/animations/starlight_smooth_anim.h @@ -5,11 +5,9 @@ RGB_MATRIX_EFFECT(STAR_LIGHT_SMOOTH) bool STAR_LIGHT_SMOOTH(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); - // initialize static array for random offsets static uint16_t time_offsets[RGB_MATRIX_LED_COUNT] = {0}; static bool initialized = false; - // initialize random offsets if (!initialized) { for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { time_offsets[i] = rand() % 65500; @@ -20,7 +18,6 @@ bool STAR_LIGHT_SMOOTH(effect_params_t* params) { for (uint8_t i = led_min; i < led_max; i++) { HSV hsv = rgb_matrix_config.hsv; - // adjustable time calculation uint16_t time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16); hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); From acd5c156a623d9c8a6bf8059ead95d58d7e994c6 Mon Sep 17 00:00:00 2001 From: hbbit-dev Date: Thu, 18 Jul 2024 20:01:51 -0700 Subject: [PATCH 3/6] (docs) effect list updated --- docs/features/rgb_matrix.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/features/rgb_matrix.md b/docs/features/rgb_matrix.md index 230eff7a36d..ed03a375844 100644 --- a/docs/features/rgb_matrix.md +++ b/docs/features/rgb_matrix.md @@ -677,6 +677,7 @@ enum rgb_matrix_effects { RGB_MATRIX_STARLIGHT, // LEDs turn on and off at random at varying brightness, maintaining user set color RGB_MATRIX_STARLIGHT_DUAL_HUE, // LEDs turn on and off at random at varying brightness, modifies user set hue by +- 30 RGB_MATRIX_STARLIGHT_DUAL_SAT, // LEDs turn on and off at random at varying brightness, modifies user set saturation by +- 30 + RGB_MATRIX_STARLIGHT_SMOOTH, // LEDs randomly and smoothly increase and decrease in brightness to create a starlight effect, speed adjustable RGB_MATRIX_RIVERFLOW, // Modification to breathing animation, offset's animation depending on key location to simulate a river flowing RGB_MATRIX_EFFECT_MAX }; From 708711c97087190839c9fdc3e6c496fc5e6b6b6a Mon Sep 17 00:00:00 2001 From: hbbit-dev Date: Sun, 28 Jul 2024 12:24:11 -0700 Subject: [PATCH 4/6] #24137 - improvement suggestions and typo fix --- quantum/rgb_matrix/animations/starlight_smooth_anim.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/quantum/rgb_matrix/animations/starlight_smooth_anim.h b/quantum/rgb_matrix/animations/starlight_smooth_anim.h index 5543bfc79d8..a85937e9579 100644 --- a/quantum/rgb_matrix/animations/starlight_smooth_anim.h +++ b/quantum/rgb_matrix/animations/starlight_smooth_anim.h @@ -1,18 +1,16 @@ #ifdef ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH -RGB_MATRIX_EFFECT(STAR_LIGHT_SMOOTH) +RGB_MATRIX_EFFECT(STARLIGHT_SMOOTH) # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -bool STAR_LIGHT_SMOOTH(effect_params_t* params) { +bool STARLIGHT_SMOOTH(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); static uint16_t time_offsets[RGB_MATRIX_LED_COUNT] = {0}; - static bool initialized = false; - if (!initialized) { + if (params->init) { for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) { - time_offsets[i] = rand() % 65500; + time_offsets[i] = random16_max(65000); } - initialized = true; } for (uint8_t i = led_min; i < led_max; i++) { From b88b761f67544865c742c810f2936b669873a93b Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 15 Oct 2024 07:10:19 -0700 Subject: [PATCH 5/6] Update quantum/rgb_matrix/animations/starlight_smooth_anim.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: フィルターペーパー <76888457+filterpaper@users.noreply.github.com> --- quantum/rgb_matrix/animations/starlight_smooth_anim.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quantum/rgb_matrix/animations/starlight_smooth_anim.h b/quantum/rgb_matrix/animations/starlight_smooth_anim.h index a85937e9579..d1f59ccfa55 100644 --- a/quantum/rgb_matrix/animations/starlight_smooth_anim.h +++ b/quantum/rgb_matrix/animations/starlight_smooth_anim.h @@ -14,13 +14,13 @@ bool STARLIGHT_SMOOTH(effect_params_t* params) { } for (uint8_t i = led_min; i < led_max; i++) { - HSV hsv = rgb_matrix_config.hsv; + RGB_MATRIX_TEST_LED_FLAGS(); uint16_t time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16); + HSV hsv = rgb_matrix_config.hsv; hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); + RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - RGB_MATRIX_TEST_LED_FLAGS(); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); } From 08f3a1c34aca542df6bdf0e7929805e00a7918a3 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 15 Oct 2024 12:23:52 -0700 Subject: [PATCH 6/6] lint --- quantum/rgb_matrix/animations/starlight_smooth_anim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/rgb_matrix/animations/starlight_smooth_anim.h b/quantum/rgb_matrix/animations/starlight_smooth_anim.h index d1f59ccfa55..45aa9e04514 100644 --- a/quantum/rgb_matrix/animations/starlight_smooth_anim.h +++ b/quantum/rgb_matrix/animations/starlight_smooth_anim.h @@ -17,7 +17,7 @@ bool STARLIGHT_SMOOTH(effect_params_t* params) { RGB_MATRIX_TEST_LED_FLAGS(); uint16_t time = scale16by8((g_rgb_timer / 2) + time_offsets[i], rgb_matrix_config.speed / 16); - HSV hsv = rgb_matrix_config.hsv; + HSV hsv = rgb_matrix_config.hsv; hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); RGB rgb = rgb_matrix_hsv_to_rgb(hsv);