extern unsigned char dots_color[3][8][4];
extern unsigned char ASCII_Number[10][8];
extern unsigned char ASCII_Char[52][8];
unsigned char State = 2;
unsigned char color=0,row=0,dots=0,position=0;
unsigned char line=0,level=0;
unsigned long timeout;
unsigned char Col_Red,Col_Blue,Col_Green;
/*
This is a hacky implementation of a RainbowDuino serial interface. You need to upload the serial sketch to the RainbowDuino device.
You cannot use multiple devices with this sketch.
If you see garbled characters, reset the RainbowDuino.
This implementation removes the inital handshake required (and advised) for I2C. This varient just sends data down the line hoping the Rainbowduino is in an appropriate state to
output to screen.
*/
void setup()
{
Serial.begin(115200); //Setup high speed Serial
}
void loop()
{
SetRGB(0x0F,0x00,0x00); // Set Colour
SentChar(10,'T'); // Send Char
delay(200); // Wait a bit (note: Serial is FAR faster than I2C)
SetRGB(0x0F,0x04,0x00);
SentChar(9,'e');
delay(200);
SetRGB(0x0F,0x0F,0x00);
SentChar(8,'a');
delay(200);
SetRGB(0x00,0x0F,0x00);
SentChar(7,'m');
delay(400);
SetRGB(0x00,0x0F,0x08);
SentChar(6,'M');
delay(200);
SetRGB(0x00,0x00,0x0F);
SentChar(5,'C');
delay(200);
SetRGB(0x0F,0x04,0x0F);
SentChar(4,'S');
delay(200);
SetRGB(0x0F,0x00,0x00);
SentChar(10,' ');
delay(200);
SetRGB(0x0F,0x00,0x00);
SentChar(10,'A');
delay(200);
SetRGB(0x0F,0x04,0x00);
SentChar(9,'t');
delay(200);
SetRGB(0x0F,0x0F,0x00);
SentChar(8,'o');
delay(200);
SetRGB(0x00,0x0F,0x00);
SentChar(7,'m');
delay(400);
SetRGB(0x00,0x0F,0x08);
SentChar(6,'R');
delay(200);
SetRGB(0x00,0x00,0x0F);
SentChar(5,'i');
delay(200);
SetRGB(0x0F,0x04,0x0F);
SentChar(4,'o');
delay(200);
SetRGB(0x0F,0x04,0x0F);
SentChar(4,'t');
delay(200);
delay(900);
}
//-------------------------------------------------------------
//Name:SendData
//Function: Master sent one buff data to RainbowDuino or sent the color data to RainbowDuino
//Parameter: ADD: RainbowDuino IIC Address
// Auto:if Auto = 1 sent the data in buff ; if Auto = 0 then sent the RGB data
// Red Green Blue: when Auto = 0 ,sent these color data to RainbowDuino
//-------------------------------------------------------------
void SendData(int ADD,int Auto,int Red,int Green,int Blue)
{
int OK=0;
int tempcol;
while(!OK)
{
switch(State)
{
case 2:
for (color=0;color<3;color++)
{
if (color==0)
{
tempcol=Green;
tempcol|=(Green<<4);
}
else if(color==1)
{
tempcol=Red;
tempcol|=(Red<<4);
}
else if(color==2)
{
tempcol=Blue;
tempcol|=(Blue<<4);
}
//// Serial.beginTransmission(ADD);
for (row=0;row<8;row++)
{
for (dots=0;dots<4;dots++)
{
// if (Auto)
Serial.write(dots_color[color][row][dots]);
// else
// Serial.write(tempcol);
}
}
// //Serial.endTransmission(); // stop transmitting
delay(5);
}
OK=1;
State=2;
break;
default:
State=2;
break;
}
}
}