Allow different speed animations for each light in spooky and eerie

This commit is contained in:
Savanni D'Gerinel 2022-07-18 23:02:47 -04:00
parent aefb2184bf
commit cf21388bd8
1 changed files with 56 additions and 62 deletions

View File

@ -149,77 +149,69 @@ void lantern_start_normal(lantern_t *self, rng_t *rng, int light_idx) {
} }
} }
/* void lantern_start_spooky(lantern_t *self, rng_t *rng, int light_idx) {
void lantern_start_spooky(lantern_t *self, rng_t *rng) { switch (light_idx) {
case 0:
animation_begin( animation_begin(
&self->animations[0], &self->animations[0],
0, 0,
random_step(self->animations[0].color.g, 80, 120, rng), random_step(self->animations[0].color.g, 80, 120, rng),
0, 0,
15); 15);
break;
case 1:
animation_begin( animation_begin(
&self->animations[1], &self->animations[1],
0, 0,
random_step(self->animations[1].color.g, 60, 100, rng), random_step(self->animations[1].color.g, 60, 100, rng),
0, 0,
15); 15);
break;
case 2:
animation_begin( animation_begin(
&self->animations[2], &self->animations[2],
0, 0,
random_step(self->animations[2].color.g, 20, 40, rng), random_step(self->animations[2].color.g, 20, 40, rng),
0, 0,
15); 15);
break;
}
} }
void lantern_start_eerie(lantern_t *self, rng_t *rng) { void lantern_start_eerie(lantern_t *self, rng_t *rng, int light_idx) {
switch (light_idx) {
case 0:
animation_begin( animation_begin(
&self->animations[0], &self->animations[0],
random_step(self->animations[0].color.g, 20, 40, rng), random_step(self->animations[0].color.g, 20, 40, rng),
random_step(self->animations[0].color.g, 20, 40, rng), random_step(self->animations[0].color.g, 20, 40, rng),
random_step(self->animations[0].color.g, 80, 120, rng), random_step(self->animations[0].color.g, 80, 120, rng),
15); 15);
break;
case 1:
animation_begin( animation_begin(
&self->animations[1], &self->animations[1],
random_step(self->animations[0].color.g, 0, 30, rng), random_step(self->animations[0].color.g, 0, 30, rng),
random_step(self->animations[0].color.g, 0, 30, rng), random_step(self->animations[0].color.g, 0, 30, rng),
random_step(self->animations[1].color.g, 60, 100, rng), random_step(self->animations[1].color.g, 60, 100, rng),
15); 30);
break;
case 2:
animation_begin( animation_begin(
&self->animations[2], &self->animations[2],
random_step(self->animations[0].color.g, 0, 10, rng), random_step(self->animations[0].color.g, 0, 10, rng),
random_step(self->animations[0].color.g, 0, 10, rng), random_step(self->animations[0].color.g, 0, 10, rng),
random_step(self->animations[2].color.g, 20, 40, rng), random_step(self->animations[2].color.g, 20, 40, rng),
15); 45);
break;
}
} }
*/
void lantern_set_mode(lantern_t *self, color_scheme_e scheme) { void lantern_set_mode(lantern_t *self, color_scheme_e scheme) {
self->color_scheme = scheme; self->color_scheme = scheme;
} }
void lantern_step(lantern_t *self, display_t *display, rng_t *rng, rgb_t colors[LIGHT_COUNT]) { void lantern_step(lantern_t *self, display_t *display, rng_t *rng, rgb_t colors[LIGHT_COUNT]) {
/*
if (!animation_running(&self->animations[0])) {
// display_lantern(display, self);
switch (self->color_scheme) {
case test:
lantern_start_test(self);
break;
case normal:
lantern_start_normal(self, rng);
break;
case spooky:
lantern_start_spooky(self, rng);
break;
case eerie:
lantern_start_eerie(self, rng);
break;
case flash:
break;
}
}
*/
for (int i = 0; i < LIGHT_COUNT; i++) { for (int i = 0; i < LIGHT_COUNT; i++) {
if (!animation_running(&self->animations[i])) { if (!animation_running(&self->animations[i])) {
switch (self->color_scheme) { switch (self->color_scheme) {
@ -227,8 +219,10 @@ void lantern_step(lantern_t *self, display_t *display, rng_t *rng, rgb_t colors[
lantern_start_normal(self, rng, i); lantern_start_normal(self, rng, i);
break; break;
case spooky: case spooky:
lantern_start_spooky(self, rng, i);
break; break;
case eerie: case eerie:
lantern_start_eerie(self, rng, i);
break; break;
case flash: case flash:
break; break;