- CODE: SELECT_ALL_CODE
void main ()
{
void putcolor2();
TRISB = 0b00000011; //Configure PORTB I/O direction
TRISC = 0b00000000;
TRISD = 0b00000000; //Configure PORTD I/O direction
PORTB = 0;
PORTC = 0;
PORTD = 0;
//sample
while(1)
{
brtdecode(0x9A, 0xCD, 0x32); // YELLOW green
putcolor2();
Delay_100msX(10);
brtdecode(0x55, 0x6B, 0x2F); // DARK OLIVE green..aqua or cyan
putcolor2();
Delay_100msX(10);
}
/********************************************************************
* Function Name: Single line serial Data 0 *
* Return Value: void *
* Parameters: None *
* Description: set data logic 0 for single serial *
* data transmission *
********************************************************************/
void SLD0()
{
SerOne = 1;
Nop();
Nop(); // works 0.4 us
Nop();
Nop();
SerOne = 0;
Nop(); //.2uS works
Nop();
Nop();
Nop();
Nop();// works - 0.85 us
Nop();
Nop();
Nop();
Nop();
Nop();
}
/********************************************************************
* Function Name: Single line serial Data 1 *
* Return Value: void *
* Parameters: None *
* Description: set data logic 1 for single serial *
* data transmission *
********************************************************************/
void SLD1()
{
SerOne = 1;
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop(); //works 0.8
SerOne = 0;
Nop();
Nop();
Nop();
Nop();
Nop(); //works 0.45 us
}
/********************************************************************
* Function Name: Put color on LED 2 *
* Return Value: void *
* Parameters: None *
* Description: l *
* *
********************************************************************/
void putcolor2()
{
for(j=0;j<24;j++)
{
if(bitz[j]==1)
{
SLD1();
}
else
{
SLD0();
}
}
//}
SerOne = 0;
Delay10TCYx(60);
}
/********************************************************************
* Function Name: Brightness Decode *
* Return Value: void *
* Parameters: None *
* Description: l *
* *
********************************************************************/
void brtdecode(int red, int grn, int blue)
{
for(j=0;j<24;j++)
{
if(j<8)
{
bitz[j]=getBit(grn,8-j);
}
if((j>=8) && (j<16))
{
bitz[j]=getBit(red,8-j%8);
}
if(j>=16)
{
bitz[j]=getBit(blue,8-j%8);
}
}
}