From 15f93285b1e94d5bf661499f75e60ae15cd0b6c9 Mon Sep 17 00:00:00 2001 From: Drashna Jael're Date: Mon, 15 Jan 2024 21:43:23 -0800 Subject: [PATCH] [RGB Matrix] Use rgb matrix hsv to rgb function in all animations --- quantum/rgb_matrix/animations/hue_breathing_anim.h | 12 +++++++++++- quantum/rgb_matrix/animations/pixel_flow_anim.h | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/quantum/rgb_matrix/animations/hue_breathing_anim.h b/quantum/rgb_matrix/animations/hue_breathing_anim.h index 60d7426cfc..dc38765ba1 100644 --- a/quantum/rgb_matrix/animations/hue_breathing_anim.h +++ b/quantum/rgb_matrix/animations/hue_breathing_anim.h @@ -11,7 +11,17 @@ hsv_t HUE_BREATHING_math(hsv_t hsv, uint8_t i, uint8_t time) { } bool HUE_BREATHING(effect_params_t* params) { - return effect_runner_i(params, &HUE_BREATHING_math); + RGB_MATRIX_USE_LIMITS(led_min, led_max); + uint8_t huedelta = 12; + hsv_t hsv = rgb_matrix_config.hsv; + uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); + hsv.h = hsv.h + scale8(abs8(sin8(time) - 128) * 2, huedelta); + rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); + for (uint8_t i = led_min; i < led_max; i++) { + 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 diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h index 35170f9588..44b4b5c481 100644 --- a/quantum/rgb_matrix/animations/pixel_flow_anim.h +++ b/quantum/rgb_matrix/animations/pixel_flow_anim.h @@ -22,7 +22,7 @@ static bool PIXEL_FLOW(effect_params_t* params) { // Clear LEDs and fill the state array rgb_matrix_set_color_all(0, 0, 0); for (uint8_t j = 0; j < RGB_MATRIX_LED_COUNT; ++j) { - led[j] = (random8() & 2) ? (rgb_t){0, 0, 0} : hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); + led[j] = (random8() & 2) ? (rgb_t){0, 0, 0} : rgb_matrix_hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); } } @@ -39,7 +39,7 @@ static bool PIXEL_FLOW(effect_params_t* params) { led[j] = led[j + 1]; } // Fill last LED - led[led_max - 1] = (random8() & 2) ? (rgb_t){0, 0, 0} : hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); + led[led_max - 1] = (random8() & 2) ? (rgb_t){0, 0, 0} : rgb_matrix_hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); // Set pulse timer wait_timer = g_rgb_timer + interval(); }