From bbc71fb5791c8cc80657bb0f668dad7805435acd Mon Sep 17 00:00:00 2001 From: lokher Date: Fri, 7 Nov 2025 17:06:20 +0800 Subject: [PATCH] Fix mixed RGB effect when both regions use JELLYBEAN_RAINDROPS When both mixed RGB regions are set it to JELLYBEAN_RAINDROPS, region 0 only updates LEDs with index < RGB_MATRIX_LED_COUNT / 5, while the rest are not updated. This happens because the effect runs in the order: region1(iter 0) -> region0(iter 0) -> region1(iter 1) -> region0(iter 1) ... both regions share the same index, causing region 0's index to be used by region 1 in later iterations and reset. Fix: store index separately for each region by converting it into an array. --- .../rgb_matrix/animations/jellybean_raindrops_anim.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h index 7dae245a96..d8fbe9cb18 100644 --- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h +++ b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h @@ -11,11 +11,12 @@ static void jellybean_raindrops_set_color(uint8_t i, effect_params_t* params) { } bool JELLYBEAN_RAINDROPS(effect_params_t* params) { - static uint16_t index = RGB_MATRIX_LED_COUNT + 1; + static uint16_t index[2] = { RGB_MATRIX_LED_COUNT + 1, RGB_MATRIX_LED_COUNT + 1 }; // TODO: more region? + uint8_t region = params->region; // Periodic trigger for LED change if ((params->iter == 0) && (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0)) { - index = random8_max(RGB_MATRIX_LED_COUNT); + index[region] = random8_max(RGB_MATRIX_LED_COUNT); } RGB_MATRIX_USE_LIMITS(led_min, led_max); @@ -25,9 +26,9 @@ bool JELLYBEAN_RAINDROPS(effect_params_t* params) { } } // Change LED once and set index out of range till next trigger - else if (led_min <= index && index < led_max) { - jellybean_raindrops_set_color(index, params); - index = RGB_MATRIX_LED_COUNT + 1; + else if (led_min <= index[region] && index[region] < led_max) { + jellybean_raindrops_set_color(index[region], params); + index[region] = RGB_MATRIX_LED_COUNT + 1; } return rgb_matrix_check_finished_leds(led_max); }