From f1aac6611d3119b0508ac2bea74aa84e37974f51 Mon Sep 17 00:00:00 2001 From: localhorst Date: Tue, 6 Jan 2026 22:21:33 +0100 Subject: [PATCH] fix random animation --- main/animation.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/main/animation.c b/main/animation.c index 654ae59..1500ddf 100644 --- a/main/animation.c +++ b/main/animation.c @@ -309,18 +309,26 @@ static void anim_random(void) uint16_t num_leds = led_get_num_leds_a() + led_get_num_leds_b(); uint16_t random_pos = random16(num_leds); - // Randomly clear all (rare event) - if (random_pos == num_leds - 1 && random8() > 200) - { - led_clear_all(); - return; - } - - // Set random LED to random color rgb_t random_color = { - random8(), - random8(), - random8()}; + 0, + 0, + 0}; + + // Set random LED to random basis color + switch (random16(3)) + { + case 0: + random_color.r = 255; + break; + case 1: + random_color.g = 255; + break; + case 2: + random_color.b = 255; + break; + default: + break; + } if (random_pos < led_get_num_leds_a()) { @@ -407,7 +415,7 @@ void animation_update(void) // anim_chase_rgb(); break; case ANIM_RANDOM: - // anim_random(); + anim_random(); break; default: anim_black();