ledControl.c 640 Bytes
#include <avr/io.h>
#include <util/delay.h>
#include <math.h>

#include "tlc5947.h"

#define	NB_DRIVERS 3
#define MAX_VALUE 80 //TODO tbd !
#define DELAY 100

int main(void){
	// Initialisation
	unsigned int ledValues[NB_DRIVERS * DLED_CHANNELS];
	init_LED_Drivers(NB_DRIVERS);

	// Animation
	unsigned int animTick = 0;
	while(1){
		// Build animation
		for(int i=0; i<NB_DRIVERS * DLED_CHANNELS; i++){
			double val = (double) (animTick % 21) / 20;
			ledValues[i] = (unsigned int) (val * MAX_VALUE);
		}

		animTick++;
		if(animTick >= 10000)
			animTick = 0;

		set_LED_Drivers(ledValues, NB_DRIVERS);
		_delay_ms(100);
	}
	return 0;
}