From 883fff95dd7139686859d24fba9559abc2ceb229 Mon Sep 17 00:00:00 2001 From: localhorst Date: Tue, 6 Jan 2026 21:55:00 +0100 Subject: [PATCH] fix rainbow animation --- main/animation.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/main/animation.c b/main/animation.c index d544356..fb0ff76 100644 --- a/main/animation.c +++ b/main/animation.c @@ -102,17 +102,21 @@ static void anim_rainbow(void) // Rainbow generator uint16_t num_leds_a = led_get_num_leds_a(); uint16_t num_leds_b = led_get_num_leds_b(); + uint16_t num_leds = num_leds_a + num_leds_b; - for (uint16_t i = 0; i < num_leds_a; i++) + for (uint16_t i = 0; i < num_leds; i++) { hsv_t hsv = {(uint8_t)(global_hue + (i * 7)), 255, 255}; - led_set_pixel_a(i, led_hsv_to_rgb(hsv)); - } + rgb_t color = led_hsv_to_rgb(hsv); - for (uint16_t i = 0; i < num_leds_b; i++) - { - hsv_t hsv = {(uint8_t)(global_hue + (i * 7)), 255, 255}; - led_set_pixel_b(i, led_hsv_to_rgb(hsv)); + if (i < num_leds_a) + { + led_set_pixel_a(num_leds_a - i - 1, color); + } + else + { + led_set_pixel_b(i - num_leds_a, color); + } } } @@ -379,7 +383,7 @@ void animation_update(void) anim_white(); break; case ANIM_RAINBOW: - // anim_rainbow(); + anim_rainbow(); break; case ANIM_RAINBOW_GLITTER: // anim_rainbow_glitter();