mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2026-02-23 09:52:37 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user