From e03485b1e56dd361a2b8c76c7098a0e8bf1793b6 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Sun, 17 Jul 2022 23:19:13 -0400 Subject: [PATCH] Fix the animation build --- flake.nix | 7 ++++--- flame/main.c | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 257aafe..10056ca 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; diff --git a/flame/main.c b/flame/main.c index 10d1ebb..6ca584c 100644 --- a/flame/main.c +++ b/flame/main.c @@ -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); } } }