# BlueMiniModule - LED matrix with 13x7 pixels
# version 0.3 date 2009-08-15
# Copyright (C) 2007 Stefan Schuermans <stefan@blinkenarea.org>
# Copyleft GNU public license, version 2
# a BlinkenArea project - http://www.blinkenarea.org/

AVRA = avra
AVRDUDE = avrdude
UISP = uisp
PROGRAMMER = stk200

.PHONY: all prog_fuses prog reset no_reset clean

all: BlueMiniModule.hex

movie.geninc: movie.txt
	<movie.txt tr -d '\n' | sed 's/[0-9]\+,[0-9]\+,/&\n/g' | sed 's/^/.DB /;s/,$$//' >movie.geninc

BlueMiniModule.hex: BlueMiniModule.asm movie.geninc
	$(AVRA) -l BlueMiniModule.lst BlueMiniModule.asm

prog_fuses:
	$(AVRDUDE) -c $(PROGRAMMER) -p m8 -u -e
	$(AVRDUDE) -c $(PROGRAMMER) -p m8 -u -U lfuse:w:0xAF:m -U hfuse:w:0xC9:m

prog: BlueMiniModule.hex
	$(AVRDUDE) -c $(PROGRAMMER) -p m8 -u -e
	$(AVRDUDE) -c $(PROGRAMMER) -p m8 -u -U flash:w:BlueMiniModule.hex

reset:
	$(AVRDUDE) -c $(PROGRAMMER) -p m8

no_reset:
	$(UISP) -dprog=$(PROGRAMMER) -dpart=atmega8

clean:
	rm -f *.geninc *.cof *.hex *.lst *.obj
