WIP: feature/esp32-ng-basic #1
@ -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 num_leds = led_get_num_leds_a() + led_get_num_leds_b();
|
||||||
uint16_t random_pos = random16(num_leds);
|
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 = {
|
rgb_t random_color = {
|
||||||
random8(),
|
0,
|
||||||
random8(),
|
0,
|
||||||
random8()};
|
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())
|
if (random_pos < led_get_num_leds_a())
|
||||||
{
|
{
|
||||||
@ -407,7 +415,7 @@ void animation_update(void)
|
|||||||
// anim_chase_rgb();
|
// anim_chase_rgb();
|
||||||
break;
|
break;
|
||||||
case ANIM_RANDOM:
|
case ANIM_RANDOM:
|
||||||
// anim_random();
|
anim_random();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
anim_black();
|
anim_black();
|
||||||
|
|||||||
Reference in New Issue
Block a user