Code:
encoder1=(Bit1_1_Data_ADDR >>4) & 0x0F;
encoder2=(Bit1_0_Data_ADDR) & 0x0F;
switch(encoder1)
{
case 0x00:
LCD_PrCString(" ");
LCD_Position(1,0);
LCD_PrCString("Case0");
Police_Primary_LightBar( );
break;
case 0x01:
LCD_PrCString(" ");
LCD_Position(1,0);
LCD_PrCString("Case1");
Police_LightBar_Secondary( );
break;
switch(encoder2)
{
case 0x00:
LCD_PrCString(" ");
LCD_Position(1,8);
LCD_PrCString("Case0");
break;
case 0x01:
LCD_PrCString(" ");
LCD_Position(1,8);
LCD_PrCString("Case1");
break;
void Police_Primary_LightBar(void)
{
int j;
//LCD_Position(1,0);
//LCD_PrCString("Police Primary");
for(j=0; j<4000; j++)
{
if(j<1000)
{
if(G_Flag1)
{
Side_Lights_LightBar( );
Test_Function4( );
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0xE0;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
Side_Lights_LightBar( );
Test_Function1( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0xc0;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
else
{
Side_Lights_LightBar( );
Test_Function4();
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0x07;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
Side_Lights_LightBar( );
Test_Function1( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0x03;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
}
else if((j>1000) && (j<2000))
{
if(G_Flag1)
{
Side_Lights_LightBar( );
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0x3C;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0x81;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
else
{
Side_Lights_LightBar( );
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0xC3;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0x3c;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
}
else if((j>2000) && (j<3000))
{
if(G_Flag1)
{
Side_Lights_LightBar( );
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0x55;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0x16;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
else
{
Side_Lights_LightBar( );
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0xAA;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
Side_Lights_LightBar( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0x61;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
}
else
{
if(G_Flag1)
{
Side_Lights_LightBar( );
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0xFF;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0x00;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
else
{
Side_Lights_LightBar( );
I2Caddr=0x20;
charcount=2;
command[0]=0x00;
command[1]=0x00;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
I2Caddr=0x20;
charcount=2;
command[0]=0x01;
command[1]=0xFF;
I2C_bWriteBytes(I2Caddr, command, charcount, I2C_CompleteXfer);
while(!(I2C_bReadI2CStatus( ) & I2CHW_WR_COMPLETE));
I2C_ClrWrStatus( );
}
}
}
so in summary when i turn the first encoder(encoder one) the police lightbar function gets called and executes which works, and then when i turn the second encoder(encoder 2) i would like for that to break the for loop