fix chase rgb animation

This commit is contained in:
2026-01-06 22:39:44 +01:00
parent d2d5d7dc4b
commit 468d2cba74

View File

@ -270,7 +270,7 @@ static void anim_chase(void)
continue;
// Calculate brightness based on distance from center
uint8_t brightness = (offset == 0) ? 255 : 64; // Center: full, trailing: 25%
uint8_t brightness = (offset == 0) ? 255 : 32; // Center: full, trailing: 12%
// Create dimmed color
rgb_t dimmed_red = {
@ -299,26 +299,46 @@ static void anim_chase_rgb(void)
// RGB cycling dot sweeping with trailing dots
led_clear_all();
uint16_t num_leds = led_get_num_leds_a() + led_get_num_leds_b();
int16_t pos = beatsin16(40, 0, num_leds - 1);
uint16_t num_leds_a = led_get_num_leds_a();
uint16_t num_leds_b = led_get_num_leds_b();
uint16_t total_leds = num_leds_a + num_leds_b;
// Get oscillating position across both strips
int16_t center_pos = beatsin16(40, 0, total_leds - 1);
hsv_t hsv = {global_hue, 255, 192};
rgb_t color = led_hsv_to_rgb(hsv);
// Set main dot and trailing dots
for (int offset = -2; offset <= 2; offset++)
// Draw center dot with dimmed trailing dots (3 dots total: center ±1)
for (int8_t offset = -1; offset <= 1; offset++)
{
int16_t led_pos = pos + offset;
if (led_pos >= 0 && led_pos < num_leds)
int16_t led_pos = center_pos + offset;
// Skip if position is out of bounds
if (led_pos < 0 || led_pos >= total_leds)
continue;
// Calculate brightness based on distance from center
uint8_t brightness = (offset == 0) ? 255 : 32; // Center: full, trailing: 12%
// Create dimmed color
rgb_t dimmed_color = {
(color.r * brightness) / 255,
(color.g * brightness) / 255,
(color.b * brightness) / 255};
// Map virtual position to physical LED
if (led_pos < num_leds_a)
{
if (led_pos < led_get_num_leds_a())
{
led_add_pixel_a(led_pos, color);
}
else
{
led_add_pixel_b(led_pos - led_get_num_leds_a(), color);
}
// Strip A (mirrored: position 0 maps to last LED)
uint16_t strip_a_index = num_leds_a - led_pos - 1;
led_set_pixel_a(strip_a_index, dimmed_color);
}
else
{
// Strip B (direct mapping)
uint16_t strip_b_index = led_pos - num_leds_a;
led_set_pixel_b(strip_b_index, dimmed_color);
}
}
}
@ -432,7 +452,7 @@ void animation_update(void)
anim_chase();
break;
case ANIM_CHASE_RGB:
// anim_chase_rgb();
anim_chase_rgb();
break;
case ANIM_RANDOM:
anim_random();