so in tlc config .h i have the number of tlc's set to 7 which should mean 112 total led's
so when column and row is set to 4 meaning 16 total led's the array runs blink free(meaning no matter what i set the RGB color to it seems to be smooth, if set to R:0 G:255 B:255 the color appears to be aqua.)
but when i set column to 16 and row to 7 then the led's appear to blink(meaning the led's appear to be off extremely briefly between transitions from red to green ...)
hopefully you can understand the code. i have not gotten around to commenting because i did not plan to publish it.
any questions just ask.
const int column = 16; // change to 16
const int row = 7; // change to 7
const byte RedPin = 6;
const byte GreenPin =7;
const byte BluePin = 8;
byte Current_Color = 'R';
struct led{
byte red;
byte green;
byte blue;
};
/*
led Box[][column] = {{{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16}}};
*/
led Box[][column] = {{{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16}},
{{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16},{0,16,16}}};
#include "tlc_config.h"
#include "Tlc5940.h"
void setup()
{
pinMode(RedPin,OUTPUT);
pinMode(GreenPin,OUTPUT);
pinMode(BluePin,OUTPUT);
digitalWrite(RedPin,LOW);
digitalWrite(GreenPin,LOW);
digitalWrite(BluePin,LOW);
Serial.begin(57600);
Tlc.init(4096/2);
startXLATCallback();
Tlc.update();
UCSR0C = UCSR0C | B00100000; // even parity
UCSR0C = UCSR0C & B11101111;
}
void loop()
{
if(Serial.available() >= (column*row+2)) Read_data();
}
// do something every two periods, so ~1024us 4 periods
#define XLAT_PERIODS 4
volatile uint8_t timesCalled;
volatile void myXLATCallback()
{
if (timesCalled != 0) timesCalled--;
else
{
timesCalled = XLAT_PERIODS;
Send_data();
Tlc.update();
}
set_XLAT_interrupt(); // so this will continue to be called
}
void startXLATCallback() {
timesCalled = XLAT_PERIODS - 1;
tlc_onUpdateFinished = myXLATCallback;
myXLATCallback();
}
void Send_data()
{
if(Current_Color == 'R')
{
for(int i=0; i < column*row ; i++)
{
Tlc.set(i, Box[i/column][i%column].red*16);
}
Turn_off();
Tlc.update();
while(tlc_needXLAT);
Turn_on();
Current_Color = 'G';
}
else if(Current_Color =='G')
{
for(int i=0; i <column*row ; i++)
{
Tlc.set(i, Box[i/column][i%column].green*16);
}
Turn_off();
Tlc.update();
while(tlc_needXLAT);
Turn_on();
Current_Color = 'B';
}
else
{
for(int i=0; i < column*row ; i++)
{
Tlc.set(i, Box[i/column][i%column].blue*16);
}
Turn_off();
Tlc.update();
while(tlc_needXLAT);
Turn_on();
Current_Color = 'R';
}
}