Commit 057ac066 authored by Fence's avatar Fence 🌈
Browse files

switch to arduino-mk & fast led for a quick prototype

parent 6089c9d8
*.elf
*.o
*.ihex
build-*
[submodule "vendor/FastLED"]
path = vendor/FastLED
url = https://github.com/FastLED/FastLED.git
CC=avr-gcc
MMCU=atmega328p
CLOCK=16000000
USER_LIB_PATH := $(shell pwd)/vendor
ARDUINO = /usr/share/arduino
ARDUINO_DIR = $(ARDUINO)
CFLAGS := -std=gnu99 -Os -Wall -ffunction-sections -fdata-sections -mmcu=$(MMCU) -DF_CPU=$(CLOCK)
LDFLAGS := -Os -mmcu=$(MMCU) -ffunction-sections -fdata-sections -Wl,--gc-sections
BOARD_TAG = uno
ARDUINO_LIBS = FastLED
SOURCES := $(wildcard src/*.c src/*/*.c)
HEADERS := $(wildcard src/*.h src/*/*.h)
OBJECTS := $(subst .c,.o, $(subst src,build, $(SOURCES)))
.Phony: clean flash
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)
$(CC) -o $@ $(OBJECTS) $(LDFLAGS)
$(OBJECTS): ./build/%.o: ./src/%.c
mkdir -p $(@D)
$(CC) -c $< -o $@ $(CFLAGS)
flash: shelf-lights.ihex
avrdude -C /etc/avrdude.conf -p $(MMCU) -c arduino -b 115200 -P /dev/ttyUSB0 -U flash:w:shelf-lights.ihex:i
clean:
rm -f shelf-lights.elf
rm -f shelf-lights.ihex
rm -rf build
include /usr/share/arduino/Arduino.mk
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 1
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define DATA_PIN 3
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2813, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
// Turn the LED on, then pause
leds[0] = CRGB::Red;
FastLED.show();
delay(500);
// Now turn the LED off, then pause
leds[0] = CRGB::Black;
FastLED.show();
delay(500);
}
#include <avr/io.h> //defines pins, ports etc
#include<util/delay.h> //functions for wasting time
int main (void) {
//init
DDRB |= (1<<PB5); //Data Direction Register B:
//writing a 1 to the Pin B5 bit enables output
//Event loop
while (1) {
PORTB = 0b00100000; //turn on 5th LED bit/pin in PORT B (Pin13 in Arduino)
_delay_ms (1000); //wait
PORTB = 0b00000000; //turn off all bits/pins on PB
_delay_ms (1000); //wait
} //end loop
return(0); //end program. This never happens.
}
Subproject commit 8b3877143287ac3e5d63934d1c8271c54035f243
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