Fix the animation build

i2c
Savanni D'Gerinel 2022-07-17 23:19:13 -04:00
parent 221dcd1541
commit e03485b1e5
2 changed files with 15 additions and 14 deletions

View File

@ -25,6 +25,7 @@
(packages."x86_64-linux"."flame" processor)
(packages."x86_64-linux"."prime-tx" processor)
(packages."x86_64-linux"."radio-rx" processor)
(packages."x86_64-linux"."interrupts" processor)
];
};
@ -75,8 +76,7 @@
};
packages."x86_64-linux"."animation" =
# { gcc, mcu, chip_select, f_cpu }:
{ gcc }:
{ gcc, mcu, chip_select, f_cpu }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in pkgs.stdenv.mkDerivation rec {
@ -267,7 +267,8 @@
(packages."x86_64-linux"."base" { inherit mcu chip_select f_cpu; })
(packages."x86_64-linux"."sk9822" { inherit mcu chip_select f_cpu; })
(packages."x86_64-linux"."rng" { inherit mcu chip_select f_cpu; })
(packages."x86_64-linux"."animation" { inherit mcu chip_select f_cpu; })
(packages."x86_64-linux"."animation" { inherit mcu chip_select f_cpu;
gcc = "${avr.gcc}/bin/avr-gcc"; })
];
CFLAGS = cflags { inherit mcu chip_select f_cpu; };

View File

@ -30,9 +30,9 @@ typedef struct {
rgb_t lamp;
color_scheme_e color_scheme;
line_t red_line;
line_t green_line;
line_t blue_line;
time_line_t red_line;
time_line_t green_line;
time_line_t blue_line;
uint8_t frame;
uint8_t duration;
@ -42,9 +42,9 @@ animation_t animation_new(void) {
return (animation_t){
.lamp = (rgb_t){ .brightness = 1, .r = 200, .g = 30, .b = 0 },
.color_scheme = normal,
.red_line = line_new(0, 0, 0, 0),
.green_line = line_new(0, 0, 0, 0),
.blue_line = line_new(0, 0, 0, 0),
.red_line = time_line_new(0, 0, 0, 0),
.green_line = time_line_new(0, 0, 0, 0),
.blue_line = time_line_new(0, 0, 0, 0),
.frame = 0,
.duration = 0,
@ -58,8 +58,8 @@ void animation_flicker(animation_t *animation, rng_t *rng) {
case normal:
rdest = random_step(animation->lamp.r, 180, 255, rng);
gdest = random_step(animation->lamp.g, 20, 50, rng);
animation->red_line = line_new(0, animation->lamp.r, 30, rdest);
animation->green_line = line_new(0, animation->lamp.g, 30, gdest);
animation->red_line = time_line_new(0, animation->lamp.r, 30, rdest);
animation->green_line = time_line_new(0, animation->lamp.g, 30, gdest);
animation->duration = 30;
break;
case creepy:
@ -76,9 +76,9 @@ void animation_step(animation_t *animation, rng_t *rng) {
animation->duration = 0;
} else {
animation->frame++;
animation->lamp.r = line_next(&animation->red_line);
animation->lamp.g = line_next(&animation->green_line);
animation->lamp.b = line_next(&animation->blue_line);
animation->lamp.r = time_line_next(&animation->red_line);
animation->lamp.g = time_line_next(&animation->green_line);
animation->lamp.b = time_line_next(&animation->blue_line);
}
}
}