From 0d0f90e91d25e5ac02c1f48f8796a4d19019c7e1 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 14 Jul 2022 19:11:23 -0400 Subject: [PATCH] Create the initial display application --- display-i2c/main.c | 27 +++++++++++++++++++++++++++ flake.nix | 23 ++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 display-i2c/main.c diff --git a/display-i2c/main.c b/display-i2c/main.c new file mode 100644 index 0000000..e02ec82 --- /dev/null +++ b/display-i2c/main.c @@ -0,0 +1,27 @@ +#include +#include + +int main(void) { + display_t display = { + .reg = { + .output = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 3 }, + .shift_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 2 }, + .latch_clock = { .ddr = &DDRB, .port = &PORTB, .pin = &PINB, .addr = 0 }, + }, + }; + + int count = 0; + while (1) { + display_init(&display); + + char msg[15]; + snprintf(msg, 15, "[%d]", count); + display_clear(&display); + display_write_message(&display, msg); + _delay_ms(1000); + + count++; + } + + return 0; +} diff --git a/flake.nix b/flake.nix index 12ab68c..87a3ac3 100644 --- a/flake.nix +++ b/flake.nix @@ -90,6 +90,7 @@ (packages."x86_64-linux"."radio-rx" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; }) (packages."x86_64-linux"."lantern" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; avr = true; }) (packages."x86_64-linux"."lantern-controller" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; avr = true; }) + (packages."x86_64-linux"."display-i2c" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; avr = true; }) ]; }; @@ -236,7 +237,7 @@ let pkgs = import nixpkgs { system = "x86_64-linux"; }; avr = pkgs.pkgsCross.avr.buildPackages; - in packages."x86_64-linux"."lantern" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; }; + in packages."x86_64-linux"."lantern" { gcc = "${avr.gcc}/bin/avr-gcc"; cflags = mcu_cflags atmega32u4; avr = true; }; packages."x86_64-linux"."lantern" = { gcc, cflags, avr }: let @@ -284,6 +285,26 @@ ]; }; + packages."x86_64-linux"."display-i2c" = + { gcc, cflags, avr }: + let + pkgs = import nixpkgs { system = "x86_64-linux"; }; + in mkProgram { + pkgs = pkgs; + gcc = gcc; + cflags = cflags; + pname = "display-i2c"; + psrc = ./display-i2c; + inherit avr; + + pbuildInputs = [ + (packages."x86_64-linux"."dio" { inherit gcc cflags; }) + (packages."x86_64-linux"."spi" { inherit gcc cflags; }) + (packages."x86_64-linux"."shift-register" { inherit gcc cflags; }) + (packages."x86_64-linux"."display" { inherit gcc cflags; }) + ]; + }; + devShell."x86_64-linux" = let pkgs = import nixpkgs { system = "x86_64-linux"; };