/* bulb - BlinkenArea ultimate logo board
Copyright (C) 2015 Martin Müllenhaupt <mm+bulb@netlair.de>
Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#define F_CPU 8000000UL // 8 MHz
#include <util/delay.h>
#include <stdlib.h>
#define ROW_COUNT 6
#define COLUMN_COUNT 7
#define MAX_ROW_TIME 16
struct Frame
{
uint8_t data[3][COLUMN_COUNT];
uint8_t time;
};
#include "animations/testbild.c"
uint8_t currentFrame = 0;
ISR(TIMER1_COMPA_vect)
{
static uint8_t row = 0;
static uint8_t timeRow = 0;
static uint16_t timeFrame = 0;
++timeRow;
if (timeRow >= MAX_ROW_TIME)
{
row = (row + 1) % ROW_COUNT;
PORTB = 0;
PORTD = ~(1 << row);
timeRow = 0;
/* upon complete draw cycle increase frame time */
if (row == 0)
{
++timeFrame;
if (timeFrame >= pgm_read_byte(&(animation[currentFrame].time))*4)
{
currentFrame = (currentFrame + 1) % ANIMATION_SIZE;
timeFrame = 0;
}
}