diff --git a/tests/atmega2560/ledControl/ledControl.c b/tests/atmega2560/ledControl/ledControl.c index 2177c39..a93b709 100644 --- a/tests/atmega2560/ledControl/ledControl.c +++ b/tests/atmega2560/ledControl/ledControl.c @@ -1,27 +1,31 @@ #include #include +#include + +#define NB_DRIVERS 3 +#define MAX_VALUE 85 //TODO tbd ! +#define DELAY 100 int main(void){ - // SCLK PIN 37 - // SIN PIN 35 - DDRC = 0x03; - uint8_t LEDs = {10, 20, 30, 40, 50, 60, 70, 80, 90, - 100, 110, 120, 130, 140, 150, 160, 170, 180, 190 - 200, 210, 220, 230, 240}; - uint8_t ANDs = {0x001, 0x002, 0x004, 0x008, 0x010, 0x020, 0x040, 0x080, - 0x100, 0x200, 0x400, 0x800}; + // Initialisation + unsigned int ledValues[NB_DRIVERS * DLED_CHANNELS]; + init_LED_Drivers(NB_DRIVERS); + // Animation + unsigned int animTick = 0; while(1){ - for(int i=0; i<24; i++){ - uint16_t n = LEDs[i] << 4; - int clkStatus = 0; - for(int j=0; j<12; j++){ - if(j == 6) - clkStatus = 1; - PORTC = (n & ANDs[j]) << 1 | clkStatus; - _delay_ms(1); - } + // Build animation + for(int i=0; i= 10000) + animTick = 0; + + set_LED_Drivers(groupes, NB_DRIVERS); + _delay_ms(100); } return 0; } diff --git a/tests/atmega2560/ledControl/tlc5947.c b/tests/atmega2560/ledControl/tlc5947.c new file mode 100644 index 0000000..7f097a8 --- /dev/null +++ b/tests/atmega2560/ledControl/tlc5947.c @@ -0,0 +1,52 @@ +#include +#include "tlc5947.h" + +#define DLED_CHANNELS 24 + +#define DDR_DLED DDRD +#define PORT_DLED PORTD + +#define PIN_DLED_CLOCK 5 +#define PIN_DLED_DATA 4 +#define PIN_DLED_LATCH 6 + +void init_LED_Drivers(int nb){ + // LED drivers I/O as outputs + DDR_DLED |= (1<=0; i--){ + // 12 bits per channel, send MSB first + int v=pwm[i]; + int j; + for(j=0; j<12; j++){ + // Set CLOCK output low + PORT_DLED &= ~(1<