fix chase animation

This commit is contained in:
2026-01-06 22:33:28 +01:00
parent f1aac6611d
commit d2d5d7dc4b

View File

@ -251,25 +251,45 @@ static void anim_chase(void)
// Red dot sweeping with trailing dots // Red dot sweeping with trailing dots
led_clear_all(); led_clear_all();
uint16_t num_leds = led_get_num_leds_a() + led_get_num_leds_b(); uint16_t num_leds_a = led_get_num_leds_a();
int16_t pos = beatsin16(40, 0, num_leds - 1); 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);
rgb_t red = {255, 0, 0}; rgb_t red = {255, 0, 0};
// Set main dot and trailing dots // Draw center dot with dimmed trailing dots (3 dots total: center ±1)
for (int offset = -2; offset <= 2; offset++) for (int8_t offset = -1; offset <= 1; offset++)
{ {
int16_t led_pos = pos + offset; int16_t led_pos = center_pos + offset;
if (led_pos >= 0 && led_pos < num_leds)
// 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 : 64; // Center: full, trailing: 25%
// Create dimmed color
rgb_t dimmed_red = {
(red.r * brightness) / 255,
(red.g * brightness) / 255,
(red.b * brightness) / 255};
// Map virtual position to physical LED
if (led_pos < num_leds_a)
{ {
if (led_pos < led_get_num_leds_a()) // Strip A (mirrored: position 0 maps to last LED)
{ uint16_t strip_a_index = num_leds_a - led_pos - 1;
led_set_pixel_a(led_pos, red); led_set_pixel_a(strip_a_index, dimmed_red);
} }
else else
{ {
led_set_pixel_b(led_pos - led_get_num_leds_a(), red); // Strip B (direct mapping)
} uint16_t strip_b_index = led_pos - num_leds_a;
led_set_pixel_b(strip_b_index, dimmed_red);
} }
} }
} }
@ -409,7 +429,7 @@ void animation_update(void)
anim_navigation(); anim_navigation();
break; break;
case ANIM_CHASE: case ANIM_CHASE:
// anim_chase(); anim_chase();
break; break;
case ANIM_CHASE_RGB: case ANIM_CHASE_RGB:
// anim_chase_rgb(); // anim_chase_rgb();