fix navigation animation

This commit is contained in:
2026-01-06 21:16:05 +01:00
parent a08dba780a
commit 12b8acf81c
6 changed files with 43 additions and 81 deletions

View File

@ -211,9 +211,7 @@ static void anim_bpm(void)
static void anim_navigation(void)
{
// Navigation lights: left red, right green, with blinking white
static uint8_t blink_state = 0;
// Navigation lights: left red, right green
led_clear_all();
uint16_t num_leds_a = led_get_num_leds_a();
@ -221,51 +219,22 @@ static void anim_navigation(void)
rgb_t red = {255, 0, 0};
rgb_t green = {0, 255, 0};
rgb_t white = {255, 255, 255};
// Left side red (first 3 LEDs of strip A)
// Side red (last 3 LEDs of strip A)
if (num_leds_a >= 3)
{
led_set_pixel_a(0, red);
led_set_pixel_a(1, red);
led_set_pixel_a(2, red);
led_set_pixel_a(num_leds_a - 1, red);
led_set_pixel_a(num_leds_a - 2, red);
led_set_pixel_a(num_leds_a - 3, red);
}
// Right side green (last 3 LEDs)
// Side green (last 3 LEDs of strip B)
if (num_leds_b >= 3)
{
led_set_pixel_b(num_leds_b - 1, green);
led_set_pixel_b(num_leds_b - 2, green);
led_set_pixel_b(num_leds_b - 3, green);
}
else if (num_leds_a >= 6)
{
led_set_pixel_a(num_leds_a - 1, green);
led_set_pixel_a(num_leds_a - 2, green);
led_set_pixel_a(num_leds_a - 3, green);
}
// Blinking white lights (positions 5-6 and 37-38 from original)
if (blink_state < FRAMES_PER_SECOND / 2)
{
if (num_leds_a > 6)
{
led_set_pixel_a(5, white);
led_set_pixel_a(6, white);
}
if (num_leds_b > 2)
{
led_set_pixel_b(1, white);
led_set_pixel_b(2, white);
}
else if (num_leds_a > 38)
{
led_set_pixel_a(37, white);
led_set_pixel_a(38, white);
}
}
blink_state = (blink_state + 1) % FRAMES_PER_SECOND;
}
static void anim_chase(void)
@ -357,31 +326,26 @@ static void anim_random(void)
esp_err_t animation_init(void)
{
current_mode = ANIM_BLACK;
global_hue = 0;
frame_counter = 0;
global_hue = 0U;
frame_counter = 0U;
ESP_LOGI(TAG, "Animation system initialized");
ESP_LOGI(TAG, "Animation initialized");
return ESP_OK;
}
void animation_set_mode(animation_mode_t mode)
{
if (mode >= ANIM_MODE_COUNT)
if ((mode >= ANIM_MODE_COUNT) || (mode < 0U))
{
mode = ANIM_BLACK;
}
current_mode = mode;
frame_counter = 0;
frame_counter = 0U;
ESP_LOGI(TAG, "Animation mode set to: %s", animation_get_mode_name(mode));
}
animation_mode_t animation_get_mode(void)
{
return current_mode;
}
void animation_update(void)
{
// Update global hue every frame (slowly cycles colors)
@ -410,31 +374,31 @@ void animation_update(void)
anim_white();
break;
case ANIM_RAINBOW:
anim_rainbow();
//anim_rainbow();
break;
case ANIM_RAINBOW_GLITTER:
anim_rainbow_glitter();
//anim_rainbow_glitter();
break;
case ANIM_CONFETTI:
anim_confetti();
//anim_confetti();
break;
case ANIM_SINELON:
anim_sinelon();
//anim_sinelon();
break;
case ANIM_BPM:
anim_bpm();
//anim_bpm();
break;
case ANIM_NAVIGATION:
anim_navigation();
break;
case ANIM_CHASE:
anim_chase();
//anim_chase();
break;
case ANIM_CHASE_RGB:
anim_chase_rgb();
//anim_chase_rgb();
break;
case ANIM_RANDOM:
anim_random();
//anim_random();
break;
default:
anim_black();
@ -456,7 +420,7 @@ const char *animation_get_mode_name(animation_mode_t mode)
"Rainbow with Glitter",
"Confetti",
"Sinelon",
"BPM",
"33BPM",
"Navigation",
"Chase",
"Chase RGB",