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"; };