Commit da4e8f03 authored by Fence's avatar Fence 🌈
Browse files

add owoLED library

parent a518d603
[submodule "vendor/owoLED"]
path = vendor/owoLED
url = https://github.com/TypicalFence/owoLED.git
CC=avr-gcc
MMCU=atmega328p
CLOCK=16000000
DEVICE=/dev/ttyACM0
CFLAGS := -std=gnu99 -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MMCU) -DF_CPU=$(CLOCK)
CFLAGS := -std=gnu99 -Os -Wall -ffunction-sections -fdata-sections
CFLAGS += -mmcu=$(MMCU) -DF_CPU=$(CLOCK)
CFLAGS += -I ./vendor/owoLED/include
LDFLAGS := -Os -mmcu=$(MMCU) -ffunction-sections -fdata-sections -Wl,--gc-sections
LDFLAGS += -L ./vendor/owoLED -lowoled
SOURCES := $(wildcard src/*.c src/*/*.c)
HEADERS := $(wildcard src/*.h src/*/*.h)
OBJECTS := $(subst .c,.o, $(subst src,build, $(SOURCES)))
LIBS := ./vendor/owoLED/libowoled.a
.Phony: clean flash
......@@ -16,17 +21,24 @@ default: shelf-lights.ihex
shelf-lights.ihex: shelf-lights.elf
avr-objcopy -O ihex -R .eeprom shelf-lights.elf shelf-lights.ihex
shelf-lights.elf: $(OBJECTS)
shelf-lights.elf: $(OBJECTS) $(LIBS)
$(CC) -o $@ $(OBJECTS) $(LDFLAGS)
$(OBJECTS): ./build/%.o: ./src/%.c
mkdir -p $(@D)
$(CC) -c $< -o $@ $(CFLAGS)
# Library targets
./vendor/owoLED/libowoled.a:
$(MAKE) -C ./vendor/owoLED libowoled.a MMCU=$(MMCU) CLOCK=$(CLOCK)
# PHONY
flash: shelf-lights.ihex
avrdude -C /etc/avrdude.conf -p $(MMCU) -c arduino -b 115200 -P /dev/ttyACM0 -D -U flash:w:shelf-lights.ihex
avrdude -C /etc/avrdude.conf -p $(MMCU) -c arduino -b 115200 -P $(DEVICE) -D -U flash:w:shelf-lights.ihex
clean:
rm -f shelf-lights.elf
rm -f shelf-lights.ihex
rm -rf build
$(MAKE) -C ./vendor/owoLED clean
#include <avr/io.h>
#include <owoLED.h>
#include <util/delay.h>
int main (void) {
DDRB |= (1 << PB0);
owoled_init();
while(1) {
owoled_toggle();
_delay_ms(500);
}
return 0;
}
while(1) {
PORTB ^= (1 << PB0);
_delay_ms(500);
}
return 0;
}
Subproject commit 463013152000f8c7113d1efc60528217ed46e5b8
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