Fix the use of LED limits (#17678)

This commit is contained in:
Albert Y 2022-07-14 19:36:51 +08:00 committed by GitHub
parent da4689d6b5
commit 1862ac5454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,24 +14,23 @@ static void raindrops_set_color(int i, effect_params_t* params) {
deltaH += 256; deltaH += 256;
} }
hsv.h = rgb_matrix_config.hsv.h + (deltaH * (rand() & 0x03)); hsv.h = rgb_matrix_config.hsv.h + (deltaH * (random8() & 0x03));
RGB rgb = rgb_matrix_hsv_to_rgb(hsv); RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
} }
bool RAINDROPS(effect_params_t* params) { bool RAINDROPS(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
if (!params->init) { if (!params->init) {
// Change one LED every tick, make sure speed is not 0 // Change one LED every tick, make sure speed is not 0
if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) { if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) {
raindrops_set_color(rand() % DRIVER_LED_TOTAL, params); raindrops_set_color(random8() % DRIVER_LED_TOTAL, params);
} }
return false; } else {
}
RGB_MATRIX_USE_LIMITS(led_min, led_max);
for (int i = led_min; i < led_max; i++) { for (int i = led_min; i < led_max; i++) {
raindrops_set_color(i, params); raindrops_set_color(i, params);
} }
}
return rgb_matrix_check_finished_leds(led_max); return rgb_matrix_check_finished_leds(led_max);
} }