Make the spooky and eerie animations more pronounced

This commit is contained in:
Savanni D'Gerinel 2022-10-30 12:11:51 -04:00
parent 196278a2fe
commit a7af4accc0
3 changed files with 39 additions and 22 deletions

View File

@ -71,7 +71,7 @@ lantern_t lantern_new(sk9822_t lights) {
sk9822_init(&lights); sk9822_init(&lights);
return (lantern_t){ return (lantern_t){
.lights = lights, .lights = lights,
.color_scheme = normal, .color_scheme = cse_off,
.animations = { .animations = {
animation_new(), animation_new(),
animation_new(), animation_new(),
@ -86,6 +86,15 @@ lantern_t lantern_new(sk9822_t lights) {
}; };
} }
void lantern_start_off(lantern_t *self, int light_idx) {
animation_begin(
&self->animations[light_idx],
0,
0,
0,
1);
}
void lantern_start_normal(lantern_t *self, int light_idx) { void lantern_start_normal(lantern_t *self, int light_idx) {
switch (light_idx) { switch (light_idx) {
case 0: case 0:
@ -157,19 +166,19 @@ void lantern_start_spooky(lantern_t *self, int light_idx) {
animation_begin( animation_begin(
&self->animations[0], &self->animations[0],
0, 0,
random_step(self->animations[0].color.g, 80, 120), random_step(self->animations[0].color.g, 40, 140),
0, 0,
5); 5);
animation_begin( animation_begin(
&self->animations[3], &self->animations[3],
0, 0,
random_step(self->animations[3].color.g, 80, 120), random_step(self->animations[3].color.g, 40, 140),
0, 0,
5); 5);
animation_begin( animation_begin(
&self->animations[6], &self->animations[6],
0, 0,
random_step(self->animations[6].color.g, 80, 120), random_step(self->animations[6].color.g, 40, 140),
0, 0,
5); 5);
break; break;
@ -177,19 +186,19 @@ void lantern_start_spooky(lantern_t *self, int light_idx) {
animation_begin( animation_begin(
&self->animations[1], &self->animations[1],
0, 0,
random_step(self->animations[1].color.g, 60, 100), random_step(self->animations[1].color.g, 20, 80),
0, 0,
5); 5);
animation_begin( animation_begin(
&self->animations[4], &self->animations[4],
0, 0,
random_step(self->animations[4].color.g, 60, 100), random_step(self->animations[4].color.g, 20, 80),
0, 0,
5); 5);
animation_begin( animation_begin(
&self->animations[7], &self->animations[7],
0, 0,
random_step(self->animations[7].color.g, 60, 100), random_step(self->animations[7].color.g, 20, 80),
0, 0,
5); 5);
break; break;
@ -197,19 +206,19 @@ void lantern_start_spooky(lantern_t *self, int light_idx) {
animation_begin( animation_begin(
&self->animations[2], &self->animations[2],
0, 0,
random_step(self->animations[2].color.g, 20, 40), random_step(self->animations[2].color.g, 10, 40),
0, 0,
5); 5);
animation_begin( animation_begin(
&self->animations[5], &self->animations[5],
0, 0,
random_step(self->animations[5].color.g, 20, 40), random_step(self->animations[5].color.g, 10, 40),
0, 0,
5); 5);
animation_begin( animation_begin(
&self->animations[8], &self->animations[8],
0, 0,
random_step(self->animations[8].color.g, 20, 40), random_step(self->animations[8].color.g, 10, 40),
0, 0,
5); 5);
break; break;
@ -289,16 +298,19 @@ void lantern_step(lantern_t *self, rgb_t colors[LIGHT_COUNT]) {
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) {
case normal: case cse_off:
lantern_start_off(self, i);
break;
case cse_normal:
lantern_start_normal(self, i); lantern_start_normal(self, i);
break; break;
case spooky: case cse_spooky:
lantern_start_spooky(self, i); lantern_start_spooky(self, i);
break; break;
case eerie: case cse_eerie:
lantern_start_eerie(self, i); lantern_start_eerie(self, i);
break; break;
case flash: case cse_flash:
break; break;
} }
} }

View File

@ -31,10 +31,11 @@ typedef struct {
} animation_t; } animation_t;
typedef enum { typedef enum {
normal, cse_off,
spooky, cse_normal,
eerie, cse_spooky,
flash cse_eerie,
cse_flash
} color_scheme_e; } color_scheme_e;
typedef struct { typedef struct {

View File

@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License along with thi
#define PULSE_ON_COUNT 5 #define PULSE_ON_COUNT 5
typedef enum { typedef enum {
lme_off,
lme_normal, lme_normal,
lme_spooky, lme_spooky,
lme_eerie, lme_eerie,
@ -137,7 +138,7 @@ int main(void) {
}; };
lantern_t lantern = lantern_new(lights); lantern_t lantern = lantern_new(lights);
lantern_set_mode(&lantern, normal); lantern_set_mode(&lantern, cse_off);
// setup_fps_timer(); // setup_fps_timer();
@ -177,14 +178,17 @@ int main(void) {
rfm_receive(&radio, (uint8_t *)msg, &length); rfm_receive(&radio, (uint8_t *)msg, &length);
if (length == 1) { if (length == 1) {
switch (msg[0]) { switch (msg[0]) {
case lme_off:
lantern_set_mode(&lantern, cse_off);
break;
case lme_normal: case lme_normal:
lantern_set_mode(&lantern, normal); lantern_set_mode(&lantern, cse_normal);
break; break;
case lme_spooky: case lme_spooky:
lantern_set_mode(&lantern, spooky); lantern_set_mode(&lantern, cse_spooky);
break; break;
case lme_eerie: case lme_eerie:
lantern_set_mode(&lantern, eerie); lantern_set_mode(&lantern, cse_eerie);
break; break;
default: default:
break; break;