Commit 1350444c authored by Fence's avatar Fence 🌈
Browse files

stuff

parent 3de3eb01
Pipeline #1253 passed with stage
in 1 minute and 7 seconds
CC=avr-gcc
MMCU=atmega328p
CLOCK=16000000
DEVICE=/dev/ttyACM0
CFLAGS := -std=gnu99 -Os -Wall -ffunction-sections -fdata-sections
CFLAGS += -mmcu=$(MMCU) -DF_CPU=$(CLOCK)
CFLAGS += -I ./vendor/owoLED/include -I ./
LDFLAGS := -Os -mmcu=$(MMCU) -ffunction-sections -fdata-sections -Wl,--gc-sections
LDFLAGS += -L ./vendor/owoLED -lowoled
CC=avr-gcc
CXX=avr-g++
LD=$(CXX) # avr-ld refuses to link libc.a
MCUFLAGS := -mmcu=$(MMCU) -DF_CPU=$(CLOCK)
INCLUDE_PATHS := -I ./vendor/owoLED/include -I ./
SOURCES := $(wildcard lib/*.c lib/*/*.c)
CFLAGS := -std=gnu99 -Os -Wall -ffunction-sections -fdata-sections
CFLAGS += $(MCUFLAGS)
CFLAGS += $(INCLUDE_PATHS)
CXXFLAGS := -std=c++11 -Os -Wall -ffunction-sections -fdata-sections
CXXFLAGS += $(MCUFLAGS)
CXXFLAGS += $(INCLUDE_PATHS)
LDFLAGS := -L ./vendor/owoLED -lowoled
C_SOURCES := $(wildcard lib/*.c lib/*/*.c)
CXX_SOURCES := $(wildcard lib/*.cc lib/*/*.cc)
HEADERS := $(wildcard lib/*.h lib/*/*.h)
OBJECTS := $(subst .c,.o, $(subst lib,build, $(SOURCES)))
C_OBJECTS := $(subst .c,.o, $(subst lib,build, $(C_SOURCES)))
CXX_OBJECTS := $(subst .cc,.o, $(subst lib,build, $(CXX_SOURCES)))
OBJECTS := $(C_OBJECTS) $(CXX_OBJECTS)
LIBS := ./vendor/owoLED/libowoled.a
.Phony: clean flash
......@@ -22,13 +33,17 @@ shelf-lights.ihex: shelf-lights.elf
avr-objcopy -O ihex -R .eeprom shelf-lights.elf shelf-lights.ihex
shelf-lights.elf: ./build/src/shelf-lights.o $(OBJECTS) $(LIBS)
$(CC) -o $@ ./build/src/shelf-lights.o $(OBJECTS) $(LDFLAGS)
$(LD) -o $@ ./build/src/shelf-lights.o $(OBJECTS) $(LDFLAGS)
build/src/shelf-lights.o: ./src/shelf-lights.c $(OBJECTS) $(LIBS)
mkdir -p $(@D)
$(CC) -c $< -o $@ $(CFLAGS)
$(CXX) -c $< -o $@ $(CXXFLAGS)
$(CXX_OBJECTS): ./build/%.o: ./lib/%.cc
mkdir -p $(@D)
$(CXX) -c $< -o $@ $(CFLAGS)
$(OBJECTS): ./build/%.o: ./lib/%.c
$(C_OBJECTS): ./build/%.o: ./lib/%.c
mkdir -p $(@D)
$(CC) -c $< -o $@ $(CFLAGS)
......
#ifndef LED_PROGRAM_HH
#define LED_PROGRAM_HH
#include <owoLED.h>
class LedProgram {
public:
virtual void run(OwOLedAddress *addr, int led_count) = 0;
};
#endif
#include "lib/programs/pride.hh"
#include <util/delay.h>
void TransPrideProgram::print_stripe(OwOLedAddress *addr, int r, int g, int b, int size) {
for (int i = 0; i<size; i++) {
owoled_send_colors(addr, r, g, b);
}
}
void TransPrideProgram::run(OwOLedAddress *addr, int led_count) {
int stripe = led_count/5;
int middle_stripe = 10; //(stripe * 5 - led_count) + stripe;
while(1) {
this->print_stripe(addr, 0x55, 0xCD, 0xFC, stripe);
this->print_stripe(addr, 0xF7, 0xA8, 0xB8, stripe);
this->print_stripe(addr, 0xFF, 0xFF, 0xFF, middle_stripe);
this->print_stripe(addr, 0xF7, 0xA8, 0xB8, stripe);
this->print_stripe(addr, 0x55, 0xCD, 0xFC, stripe);
owoled_show();
_delay_ms(1000);
}
}
#ifndef PRIDE_HH
#define PRIDE_HH
#include "../led_program.hh"
class TransPrideProgram: LedProgram {
public:
void run(OwOLedAddress *addr, int led_count);
private:
void print_stripe(OwOLedAddress *addr, int r, int g, int b, int size);
};
#endif
#include "./shelf.h"
#include "./programs/pride.hh"
void run_program(OwOLedAddress *addr, int led_count) {
TransPrideProgram prog = TransPrideProgram();
prog.run(addr, led_count);
}
#ifndef TEST_H
#define TEST_H
#ifndef SHELF_H
#define SHELF_H
#include <owoLED.h>
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#include <owoLED.h>
void draw_cool_stuff(OwOLedAddress *addr, int size);
void run_program(OwOLedAddress *addr, int led_count);
#ifdef __cplusplus
}
......
#include <owoLED.h>
void draw_cool_stuff(OwOLedAddress *addr, int size) {
for (int i = 0; i<size/2; i++) {
owoled_send_colors(addr, 0x00, 0x10, 0x10);
}
for (int i = 0; i<size/2; i++) {
owoled_send_colors(addr, 0x10, 0x00, 0x10);
}
}
#include <owoLED.h>
#include <util/delay.h>
#include <avr/io.h>
#include "lib/test.h"
#include "lib/shelf.h"
#define PIXELS 60 // Number of pixels in the string
int main (void) {
OwOLedAddress addr = owoled_init(&PORTB, &DDRB, 1);
run_program(&addr, PIXELS);
while (1) {
draw_cool_stuff(&addr, PIXELS);
owoled_show();
_delay_ms(10);
}
//owoled_send_colors(&addr, 0x00, 0x10, 0x10);
//owoled_send_colors(&addr, 0x00, 0x10, 0x10);
//owoled_send_colors(&addr, 0x00, 0x10, 0x10);
owoled_show();
return 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment