Refactoring
This commit is contained in:
parent
565036547c
commit
1f394f20ff
|
@ -1,9 +1,8 @@
|
||||||
#include "../base.h"
|
#include "base.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rng_t rng_new(uint8_t seed) {
|
rng_t rng_new(uint8_t seed) {
|
||||||
return { .mod = 255, .a = 253, .c = 41, .seed = seed };
|
rng_t rng = { .mod = 255, .a = 253, .c = 41, .seed = seed };
|
||||||
|
return rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t rng_sample(rng_t *state) {
|
uint8_t rng_sample(rng_t *state) {
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
#ifndef __BASE_H__
|
#ifndef __BASE_H__
|
||||||
#define __BASE_H__
|
#define __BASE_H__
|
26
flake.nix
26
flake.nix
|
@ -11,21 +11,6 @@
|
||||||
supportedSystems = [ "x86_64-linux" "avr-none" ];
|
supportedSystems = [ "x86_64-linux" "avr-none" ];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
packages.base."x86_64-linux" =
|
|
||||||
let pkgs = import nixpkgs { system = "x86_64-linux"; };
|
|
||||||
in pkgs.stdenv.mkDerivation rec {
|
|
||||||
name = "wearables-base";
|
|
||||||
src = "./base";
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/include
|
|
||||||
cp include/base.h $out/include
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
defaultPackage."x86_64-linux" =
|
defaultPackage."x86_64-linux" =
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
|
@ -41,7 +26,11 @@
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
set -x
|
set -x
|
||||||
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base/include/ -o main.elf ${src}/prototype/src/main.c
|
|
||||||
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -o base.o -c ${src}/base/base.c
|
||||||
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -o sk9822.o -c ${src}/sk9822/sk9822.c
|
||||||
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -I${src}/base -I${src}/sk9822 -o main.o -c ${src}/flame/main.c
|
||||||
|
${avr.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf main.o sk9822.o base.o
|
||||||
$OBJCOPY -O ihex main.elf main.hex
|
$OBJCOPY -O ihex main.elf main.hex
|
||||||
'';
|
'';
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
@ -49,7 +38,6 @@
|
||||||
cp main.elf main.hex $out
|
cp main.elf main.hex $out
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
devShell."x86_64-linux" =
|
devShell."x86_64-linux" =
|
||||||
let
|
let
|
||||||
|
@ -67,8 +55,8 @@
|
||||||
name = "Wearables-shell";
|
name = "Wearables-shell";
|
||||||
buildInputs = avr;
|
buildInputs = avr;
|
||||||
|
|
||||||
GCC="${pkgs.pkgsCross.avr.buildPackages.gcc}";
|
GCC = pkgs.pkgsCross.avr.buildPackages.gcc;
|
||||||
AVR="${pkgs.avrlibc}";
|
SIMAVR = pkgs.pkgsCross.avr.buildPackages.simavr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
#include <base.h>
|
#include <base.h>
|
||||||
#include "sk9822.h"
|
#include <sk9822.h>
|
||||||
|
|
||||||
uint8_t random_step(uint8_t value, uint8_t min, uint8_t max, rng_t *rng) {
|
uint8_t random_step(uint8_t value, uint8_t min, uint8_t max, rng_t *rng) {
|
||||||
int8_t step = (rng_sample(rng) % 32) - 16;
|
int8_t step = (rng_sample(rng) % 32) - 16;
|
|
@ -9,15 +9,20 @@ OBJECTS= main.o \
|
||||||
|
|
||||||
.SUFFIXES: .c .o .h
|
.SUFFIXES: .c .o .h
|
||||||
|
|
||||||
%.o: %.c %.h
|
|
||||||
${GCC}/bin/avr-gcc ${CFLAGS} ${AVR}/avr/include -I../base/include/ -o $@ -c $<
|
# /nix/store/fymsi5yk07jvcbdaka6nfhx6s2a7kgpi-avr-stage-final-gcc-debug-wrapper-10.3.0/bin/avr-gcc -O -finline-functions -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -DF_CPU=8000000 -std=gnu99 -D__AVR_ATtiny85__=1 -mmcu=attiny85 -I../base/include/ -E -o main.E src/main.c
|
||||||
|
|
||||||
|
|
||||||
main: main.o sk9822.o
|
main: main.o sk9822.o
|
||||||
# ${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -E -o main.E src/main.c
|
# ${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -E -o main.E src/main.c
|
||||||
# ${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -S -o main.S src/main.c
|
# ${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -S -o main.S src/main.c
|
||||||
|
echo ${GCC}
|
||||||
${GCC}/bin/avr-gcc ${CFLAGS} ${LINKFLAGS} -I../base/include/ -o main.elf main.o sk9822.o
|
${GCC}/bin/avr-gcc ${CFLAGS} ${LINKFLAGS} -I../base/include/ -o main.elf main.o sk9822.o
|
||||||
${OBJCOPY} -O ihex main.elf main.hex
|
${OBJCOPY} -O ihex main.elf main.hex
|
||||||
|
|
||||||
|
%.o: %.c %.h
|
||||||
|
${GCC}/bin/avr-gcc ${CFLAGS} -I../base/include/ -o $@ -c $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm *.o make.elf main.hex main.S main.E
|
rm *.o make.elf main.hex main.S main.E
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include "sk9822.h"
|
||||||
|
|
||||||
void send_byte(io_pin_t data_pin, io_pin_t clock_pin, uint8_t byte) {
|
void send_byte(io_pin_t data_pin, io_pin_t clock_pin, uint8_t byte) {
|
||||||
for (int i = 7; i >= 0; i--) {
|
for (int i = 7; i >= 0; i--) {
|
||||||
if (byte & _BV(i)) {
|
if (byte & _BV(i)) {
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
#include <base.h>
|
||||||
|
|
||||||
|
#ifndef __SK9822_H__
|
||||||
|
#define __SK9822_H__
|
||||||
|
|
||||||
typedef struct RGB_s {
|
typedef struct RGB_s {
|
||||||
uint8_t brightness;
|
uint8_t brightness;
|
||||||
|
@ -8,3 +12,5 @@ typedef struct RGB_s {
|
||||||
} rgb_t;
|
} rgb_t;
|
||||||
|
|
||||||
void send_pixels(io_pin_t data_pin, io_pin_t clock_pin, rgb_t *pixels, uint8_t count);
|
void send_pixels(io_pin_t data_pin, io_pin_t clock_pin, rgb_t *pixels, uint8_t count);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue