void DisplayTimeToLCD( unsigned char* pTimeArray )   // Displays time in HH:MM:SS AM/PM format
{
	ClearLCDScreen();      // Move cursor to zero location and clear screen

	// Display Hour
	WriteDataToLCD( (pTimeArray[2]/10)+0x30 );
	WriteDataToLCD( (pTimeArray[2]%10)+0x30 );

	//Display ':'
	WriteDataToLCD(':');

	//Display Minutes
	WriteDataToLCD( (pTimeArray[1]/10)+0x30 );
	WriteDataToLCD( (pTimeArray[1]%10)+0x30 );

	//Display ':'
	WriteDataToLCD(':');

	//Display Seconds
	WriteDataToLCD( (pTimeArray[0]/10)+0x30 );
	WriteDataToLCD( (pTimeArray[0]%10)+0x30 );

	//Display Space
	WriteDataToLCD(' ');

	// Display mode
	switch(pTimeArray[3])
	{
	case AM:	WriteStringToLCD("AM");	break;
	case PM:	WriteStringToLCD("PM");	break;

	default: WriteDataToLCD('H');	break;
	}
}
void Displaystring(void)
{
	ClearLCDScreen();
  WriteDataToLCD('N');
	WriteDataToLCD('O');
	WriteDataToLCD('-');
	WriteDataToLCD('V');
	WriteDataToLCD('E');
	WriteDataToLCD('H');
	WriteDataToLCD('I');
	WriteDataToLCD('C');
	WriteDataToLCD('L');
	WriteDataToLCD('E');
}
int Platform_call_named_feature(char *funcname) {
	switch (funcname[0]) {
	case 'y':
		if (strcmp(funcname,"yield")==0) {
			yield();
			return 0;
		}
		break;
	case 'P':
		if (strcmp(funcname,"PokerGame")==0) {
			//PokerGame();
			return 0;
		}
		if (strcmp(funcname,"PollSleepSemaphore")==0) {
			// Grab and release the sleep semaphore.
			// If the UI thread is trying to put the terminal to sleep, these calls will hang until the sleep has ended.
			sem_wait(&SleepSemaphore);
			// Once the semaphore is acquired, immediately give it back up.
			sem_post(&SleepSemaphore);
		}
		break;

	case 'R':


		// ResetSMDL is accessed at the password menu, and applies to Verix only.
		// When set, it opens up the clock to be downloaded or controlled via COM1 immediately upon reboot.
		// This is basically a backdoor.  It can be used to reload programming
		if (strcmp(funcname,"ResetSMDL")==0) {
			ClearLCDScreen();
			printfLCD("SMDL has been set.\r\n"
			   "%s to reboot now.\r\n"
			   "%s to return to clock app.", LCDCancelKey, LCDEnterKey);
			put_env("*SMDL","1",1);
//			ShowPressEnterOrCancel();
//			if (GetEnterOrCancel() == FALSE) SVC_RESTART("");
			return 0;
		}
		break;
	case 'K':
		if (strcmp(funcname,"Keyclick")==0) {
			Platform_normal_tone();
			return 0;
		}
	}

	return -1;
}
Beispiel #4
0
void main()
{
	P1=0x00;
	P2=0x00;
	SerialInput();
	InitLCD();
	EA=1;
	ES=1;
	EX1=1;
	
	while(1)
	{
		ClearLCDScreen();
		WriteStringToLCD("IDLE");
		delayms(100);
	}
}
Beispiel #5
0
main()
{
P2=0xff; //make output port
SerialInput();
InitLCD();
EA=1;
ES=1;
while(1)
{
ClearLCDScreen();
while(ps2_clk==1);
keyval=scan_data();
WriteDataToLCD(keyval);
encrypt_data=keyval+3
35SerialTransmit();
delayms(100);
}
}
// Displays time in HH:MM:SS format
void DisplayTimeToLCD( unsigned int h, unsigned int m, unsigned int s, unsigned char State )   
{
	ClearLCDScreen();      // Move cursor to zero location and clear screen

	if(State == CONFIG_HR_STATE)
	{
		WriteDataToLCD( ' ' );	// Display Spaces
		WriteDataToLCD( ' ' );		
	}
	else
	{
		WriteDataToLCD( (h/10)+0x30 );	// Display Hour
		WriteDataToLCD( (h%10)+0x30 );
	}

	//Display ':'
	WriteDataToLCD(':');

	if(State == CONFIG_MIN_STATE)
	{
		WriteDataToLCD( ' ' );	// Display Spaces
		WriteDataToLCD( ' ' );		
	}
	else
	{
		WriteDataToLCD( (m/10)+0x30 );	//Display Minutes
		WriteDataToLCD( (m%10)+0x30 );
	}

	//Display ':'
	WriteDataToLCD(':');

	if(State == CONFIG_SEC_STATE)
	{
		WriteDataToLCD( ' ' );	// Display Spaces
		WriteDataToLCD( ' ' );		
	}
	else
	{
		WriteDataToLCD( (s/10)+0x30 );	//Display Seconds
		WriteDataToLCD( (s%10)+0x30 );
	}
}
void FloatToLCD(float fval)
{
	
	 int value;
	char digit;
	ClearLCDScreen();// to clear the scree at the end of eah second and to display the text for 1 sec and then to refresh
	WriteDataToLCD('S');
	WriteDataToLCD('P');
	WriteDataToLCD('E');
	WriteDataToLCD('E');
	WriteDataToLCD('D');
	WriteDataToLCD(':');
  value= fval * 100; // to make the flaot forexample 4.07 to 407 and then dispaly it as charater
	digit = (value/100)%10;
	WriteDataToLCD('0'+digit);				         //Display '4'
	WriteDataToLCD('.');	
	digit = (value/10)%10;                      // Display '.'
	WriteDataToLCD('0'+digit);				         //Display '5'
  digit = (value)%10;
	WriteDataToLCD('0'+digit);				         //Display '7'
	return;
}
Beispiel #8
0
int main(void)
{

    ind = 0;
	// Setup functions for operation
	CP0Init();
	INTInitialize();
	ADCSetup();
	SetupButtons();
	SetupIO();
	SetupT1CountINT();
	SetupTimer2_3PWM();
        //SetupUART(115200);
        NU32_EnableUART2Interrupt();


	// Wait until LCD screen comes up
	wait(1000);	wait(1000);	wait(1000); wait(1000);
	LCDConfig();
	LCDSetup();


        ClearLCDScreen();

        char msg[32];
        sprintf(msg,"UART demo. Press A to start");
	WriteLCD(1,msg);

        int button = 1;
        while(button == 1) {
            button = BUTTON_A;
        }
        wait(1000);
        while(button == 0)
        {
            button = BUTTON_A;
        }
        wait(1000);
        
        // send dollar signs to enter command mode
        char send1[] = "$$$";
        SerialTransmit(send1);

        wait(1000);wait(1000);wait(1000);
        // print message and wait for press
/*        ClearLCDScreen();
        wait(1000);wait(1000);wait(1000);
        sprintf(msg,"command mode. press A");
	WriteLCD(1,msg);
        wait(1000);wait(1000);wait(1000);
        button = 1;
        while(button == 1) {
            button = BUTTON_A;
        }
        wait(1000);
        while(button == 0)
        {
            button = BUTTON_A;
        }
        wait(1000);
        wait(1000);
*/
        while(next == 0);
        next = 0;

        char send2[] = "GB\n";
        SerialTransmit(send2);

        while(1)
        {
            ClearLCDScreen();
            WriteLCD(0,string);
            wait(10000);
            wait(10000);
            wait(10000);
        }

        // receive response from chip
        char temp[4];
        SerialReceive(temp, 4, CHAR_MODE);
        
//        // print response to lcd
//        ClearLCDScreen();
//        WriteLCD(1,temp);
        

        
        char temp2[32];
        SerialReceive(temp2, 32, HEX_MODE);

        ClearLCDScreen();
        WriteLCD(1,temp2);


 /*
  * Software State machine
  *     POR:
  *         Try to connect
  *
  *
  */

        return 0;
}
Beispiel #9
0
int main (int argc, char *argv[])
{
	char LastKeypress=0;
	int LastKeypressCount=0;
	
	// Get handles to system devices
	hConsole = open(DEV_CONSOLE,0);
	hMagReader = open(DEV_CARD,0);
	hPrinter = open(DEV_COM4,0);
	
	// Switch to a font where each character is 16x16 so the entire screen space can be utilized
	setfont("CARDS.VFT");
	InitLCDGraphics();
	
	
	// remainder of initialization stuff goes here.
	// read saved configuration file from filesystem.
	// put up the network, start talking to the server.
	
	while (1) {
		char c;
		char timebuf[20];
	
		EnableScreenBuffering(TRUE);
		ClearLCDScreen();	
		
		// put the menu options at absolute positions on the screen.
		// The \x15\x16 are special characters in the font that print an "F1" button in the space
		// of two characters.  The LCD functions interpret \b as "bold" (yes, the backspace character)
		// and \n as "normal" (yes, the newline character), and \r as a newline.
		CurrentYPixelPosition = 4;
		printLCDrj(0,"\nNew Address \x15\x16");
		CurrentYPixelPosition = 20;
		printLCDrj(0,"Alerts \x15\x17");
		CurrentYPixelPosition = 36;
		printLCDrj(0,"Scan Payment \x15\x18");
		CurrentYPixelPosition = 52;
		printLCDrj(0,"Utils \x15\x19");
		CurrentYPixelPosition = 0;
		
		// todo: poll the server to get the current exchange rate
		// dummy stuff goes here instead:
		printfLCD("\bBITCOIN\r\n\r\n\b%s\r\nBuy: %s\r\nSell: %s\r\r","MtGox","5.01","4.97");
		
		// Put the current time and date
		Platform_read_realtime_clock(timebuf);
		printfLCD("%c%c:%c%c:%c%c",timebuf[8],timebuf[9],timebuf[10],timebuf[11],timebuf[12],timebuf[13]);
		

		// Will draw the bitmap to the screen unless it is identical to what's on the screen now
		EnableScreenBuffering(FALSE);
		
		// poll the keypad
		c = Platform_GetKeyFromKeypad(0);
		if (c==0) {
			Platform_sleep_ms(100);
			continue;
		}
		
		// count repeat keypresses to trigger menus that must be reached by * * and # #
		if (LastKeypress==c) {
			LastKeypressCount++;
		} else {
			LastKeypressCount=1;
			LastKeypress=c;
		}
		
		switch (c) {
		case 'A': // F1
			Menu_NewAddress();
			break;
		case 'B': // F2			
			//Menu_Alerts();
			break;			
		case 'C': // F3
			//Menu_ScanPayment();
			break;
		case 'D': // F4
			//Menu_Utils();
			break;		
		case '*':
			if (LastKeypressCount==2) {
				//Menu_Admin();
			}
			break;
		case '#':
			if (LastKeypressCount==2) {
				//Menu_Dispenser();
			}		
			break;
		}
	}
}
Beispiel #10
0
void Menu_NewAddress(void) {

	int x,y;
	QRcode *code;
	unsigned char *curdot;
	int usedoublewidth=1;
	code = QRcode_encodeString("You asked for change, we gave you coins",0,QR_ECLEVEL_M,QR_MODE_8,1);
	
	if (code <= 0) {
		ClearLCDScreen();
		printfLCD("null, errno=%d", errno);
		Platform_GetKeyFromKeypad(120);
		return;
	}		

	curdot = code->data;
	if (code->width > 32) usedoublewidth=0;
	
	EnableScreenBuffering(TRUE);
	ClearLCDScreen();
	
	
	
	for (y=0; (y/2) < code->width && y<64; y++) {
		char *bufindex;
		unsigned char mask;
		curdot = &(code->data)[(y/2) * code->width];
		bufindex = &ScreenBuffer[(y/8) * 128 + (64 - code->width)]; 
		mask = 1 << (y & 7);
		for (x=0; x < code->width; x++) {
			if (*curdot & 1) {
				if (usedoublewidth) *bufindex++ |= mask;
				*bufindex++ |= mask;
			} else {
			    if (usedoublewidth) bufindex++;
				bufindex++;
			}
			curdot++;
		}
		if (usedoublewidth==0) y++;
	}
	
	
	EnableScreenBuffering(FALSE);

	// now send it to the printer.
	// put the printer in raster graphics mode.
	write(hPrinter, "\x1b" "g", 2);

	// send one line at a time.  each cell is 6x6 pixels.
	for (y=0; y < code->width; y++) {
		int r;
		char printbuf[60];
		for (r=0; r<6; r++) {
			curdot = &(code->data)[y * code->width];
			for (x=0; x < code->width; x++) {
				if (*curdot++ & 1) {
					printbuf[x]=0xff;
				} else {
					printbuf[x]=0xc0;
				}
			}
			printbuf[code->width] = 0x21; // line terminator
			write(hPrinter, printbuf, code->width+1);
			// todo: properly poll the printer status to determine how full the buffer is
			Platform_sleep_ms(10);			
		}
	}

	write(hPrinter, ")\n\n\n\n\n\n\n", 8);
	
	
	QRcode_free(code);
	Platform_GetKeyFromKeypad(120);
}
Beispiel #11
0
void displayState4(void) {
    ClearLCDScreen();
    unsigned int h;
    unsigned int m;
    unsigned int s;
    h = 0;
    m = 0;
    s = 0;
    if (!RA1) {
        state++;
        if (state == 5) {
            state = 1;
        }
    }
    while (1) {
        WriteCommandToLCD(0x80);
        WriteStringToLCD("     ALARM     ");
        WriteCommandToLCD(0xc0);
        WriteTempToLCD(h);
        WriteStringToLCD(":");
        WriteTempToLCD(m);
        WriteStringToLCD(":");
        WriteTempToLCD(s);
        if (!RA1) {
            DisplayFirstTimeToLCD(Get_DS1307_RTC_Time());
            //DisplayDateOnLCD(Get_DS1307_RTC_Date());
            break;
        }
        while (1) {
            if (RA4 == 0) {
                switch_state++;
                if (switch_state == 4) {
                    break;
                }
            }
            if (RA1 == 0) {
                state = 1;
                break;
            }
            switch (switch_state) {
                case 1:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("    HOUR     ");
                    if (RA2 == 0 && h < 24) {
                        h++;
                        WriteCommandToLCD(0xc0);
                        WriteTempToLCD(h);
                    }
                    if (RA3 == 0 && h > 0) {
                        h--;
                        WriteCommandToLCD(0xc0);
                        WriteTempToLCD(h);
                    }
                    break;

                case 2:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("     MINUTE    ");
                    if (RA2 == 0 && m < 60) {
                        m++;
                        WriteCommandToLCD(0xc0 + 3);
                        WriteTempToLCD(m);
                    }
                    if (RA3 == 0 && m > 0) {
                        m--;
                        WriteCommandToLCD(0xc0 + 3);
                        WriteTempToLCD(m);
                    }
                    break;
                case 3:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("    SECOND   ");
                    if (RA2 == 0) {
                        s++;
                        WriteCommandToLCD(0xc0 + 6);
                        WriteTempToLCD(s);
                    }
                    if (RA3 == 0 && s > 0) {
                        s--;
                        WriteCommandToLCD(0xc0 + 6);
                        WriteTempToLCD(s);
                    }
                    break;
            }
            h_alarm = h;
            m_alarm = m;
            s_alarm = s;
        }
    }

}
Beispiel #12
0
void displayState3(void) {
    ClearLCDScreen();
    //kh?i t?o các bi?n l?u th? ngày tháng n?m
    unsigned int d;
    unsigned int m;
    unsigned int y;
    unsigned int w;
    d = (int) Get_DS1307_RTC_Date()[1];
    m = (int) Get_DS1307_RTC_Date()[2];
    y = (int) Get_DS1307_RTC_Date()[3];
    w = (int) Get_DS1307_RTC_Date()[0];
    if (!RA1) {
        state++;
        if (state == 5) {
            state = 1;
        }
    }
    while (1) {
        WriteCommandToLCD(0x80);
        WriteStringToLCD("  SETTING DATE   ");
        WriteCommandToLCD(0xc0);
        WriteTempToLCD(d);
        WriteStringToLCD(":");
        WriteTempToLCD(m);
        WriteStringToLCD(":");
        WriteTempToLCD(y);
        WriteStringToLCD(" ");
        switch (w) {
            case Monday: WriteStringToLCD("MON");
                break;
            case Tuesday: WriteStringToLCD("TUE");
                break;
            case Wednesday: WriteStringToLCD("WED");
                break;
            case Thursday: WriteStringToLCD("THU");
                break;
            case Friday: WriteStringToLCD("FRI");
                break;
            case Saturday: WriteStringToLCD("SAT");
                break;
            case Sunday: WriteStringToLCD("SUN");
                break;

            default: WriteStringToLCD("???");
                break;
        }

        if (!RA1) break;
        while (1) {
            if (RA4 == 0) {
                switch_state++;
                if (switch_state == 4) {
                    break;
                }
            }
            if (RA1 == 0) {
                state = 4;
                break;
            }
            switch (switch_state) {
                case 1:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("  CHANGE DAY   ");
                    if (RA2 == 0 && d < 31) {
                        d++;
                        WriteCommandToLCD(0xc0);
                        WriteTempToLCD(d);
                    }
                    if (RA3 == 0 && d > 0) {
                        d--;
                        WriteCommandToLCD(0xc0);
                        WriteTempToLCD(d);
                    }
                    break;

                case 2:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("   CHANGE MONTH    ");
                    if (RA2 == 0 && m < 12) {
                        m++;
                        WriteCommandToLCD(0xc0 + 3);
                        WriteTempToLCD(m);
                    }
                    if (RA3 == 0 && m > 0) {
                        m--;
                        WriteCommandToLCD(0xc0 + 3);
                        WriteTempToLCD(m);
                    }
                    break;
                case 3:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("  CHANGE YEAR  ");
                    if (RA2 == 0) {
                        y++;
                        WriteCommandToLCD(0xc0 + 6);
                        WriteTempToLCD(y);
                    }
                    if (RA3 == 0 && y > 0) {
                        y--;
                        WriteCommandToLCD(0xc0 + 6);
                        WriteTempToLCD(y);
                    }
                    break;
                case 4:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD(" CHANGE WEEK DAY  ");
                    if (RA2 == 0 && w <= 7) {
                        w++;
                    }
                    if (RA3 == 0 && w >= 1) {
                        w--;
                    }
                    WriteCommandToLCD(0xc0 + 9);
                    switch (w) {
                        case Monday: WriteStringToLCD("MON");
                            break;
                        case Tuesday: WriteStringToLCD("TUE");
                            break;
                        case Wednesday: WriteStringToLCD("WED");
                            break;
                        case Thursday: WriteStringToLCD("THU");
                            break;
                        case Friday: WriteStringToLCD("FRI");
                            break;
                        case Saturday: WriteStringToLCD("SAT");
                            break;
                        case Sunday: WriteStringToLCD("SUN");
                            break;
                        default: WriteStringToLCD("???");
                            break;
                    }
                    break;
            }
            Set_DS1307_RTC_Date(d, m, y, w);
        }
    }

}
Beispiel #13
0
void displayState2(void) {
    ClearLCDScreen();
    //Ba bi?n h,m,s l?u l?i th?i gian hi?n t?i
    unsigned int h;
    unsigned int m;
    unsigned int s;
    h = (int) Get_DS1307_RTC_Time()[2];
    m = (int) Get_DS1307_RTC_Time()[1];
    s = (int) Get_DS1307_RTC_Time()[0];
    //B?m nút chuy?n tr?ng thái
    if (!RA1) {
        state++;
        if (state == 5) {
            state = 1;
        }
    }
    //S?a th?i gian
    while (1) {
        WriteCommandToLCD(0x80);
        WriteStringToLCD("  SETTING TIME");
        WriteCommandToLCD(0xc0);
        WriteTempToLCD(h);
        WriteStringToLCD(":");
        WriteTempToLCD(m);
        WriteStringToLCD(":");
        WriteTempToLCD(s);
        if (!RA1) break;
        while (1) {
            //Khi nút switch ???c b?m s? chuy?n qua các ch? ?? ?i?u ch?nh khác
            if (RA4 == 0) {
                switch_state++;
                if (switch_state == 4) {
                    break;
                }
            }
            //Chuy?n tr?ng thái
            if (RA1 == 0) {
                state = 3;
                break;
            }
            switch (switch_state) {
                case 1:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("   CHANGE HOUR     ");
                    if (RA2 == 0 && h < 24) {
                        h++;
                        WriteCommandToLCD(0xc0);
                        WriteTempToLCD(h);
                    }
                    if (RA3 == 0 && h > 0) {
                        h--;
                        WriteCommandToLCD(0xc0);
                        WriteTempToLCD(h);
                    }
                    break;

                case 2:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("   CHANGE MINUTE   ");
                    if (RA2 == 0 && m < 60) {
                        m++;
                        WriteCommandToLCD(0xc0 + 3);
                        WriteTempToLCD(m);
                    }
                    if (RA3 == 0 && m > 0) {
                        m--;
                        WriteCommandToLCD(0xc0 + 3);
                        WriteTempToLCD(m);
                    }
                    break;
                case 3:
                    WriteCommandToLCD(0x80);
                    WriteStringToLCD("  CHANGE SECOND  ");
                    if (RA2 == 0) {
                        s++;
                        WriteCommandToLCD(0xc0 + 6);
                        WriteTempToLCD(s);
                    }
                    if (RA3 == 0 && s > 0) {
                        s--;
                        WriteCommandToLCD(0xc0 + 6);
                        WriteTempToLCD(s);
                    }
                    break;
            }
            //L?u l?i th?i gian v?a thay ??i
            Set_DS1307_RTC_Time(PM_Time, h, m, s);
        }
    }

}
Beispiel #14
0
int main(void)
{
	int delay;
	d2 = 0;
	d1 = 0;
	state = 0;
	reset = 1;
	adc1 = 0;
	adc2 = 0;
	led = 0;
	pwm = 0;
	double volt1 = 0.0;
	double volt2 = 0.0;

	// Setup functions for operation
	CP0Init();
	INTInitialize();
	ADCSetup();
	SetupButtons();
	SetupIO();
	SetupT1CountINT();
	SetupTimer2_3PWM();

	// Wait until LCD screen comes up
	wait(1000);	wait(1000);	wait(1000); wait(1000);
	LCDConfig();
	LCDSetup();

	

	// Start the timer
	T1CONbits.ON = 1;

	while(1)
	{
    		if(reset == 1)
		{
			ClearLCDScreen();
			sprintf(string,"A = Cmd button");
			WriteLCD(1,string);
			reset = 0;
			state = 0;
		}
		else
		{
			switch(state)
			{
				case 0:
					if(state_init[0] != 0)
						state_init[0] = 0;
					wait(100);
					break;
				case 1:
					if(state_init[0] != 1)
					{
						state_init[0] = 1;
						if(state_init[1] == 0)
							state_init[1] = 1;
						else
							state_init[1] = 0;
					}
					wait(100);
					break;
				case 2:
					if(state_init[0] != 2)
					{
						state_init[0] = 2;
						if(state_init[2] == 0)
							state_init[2] = 1;
						else
							state_init[2] = 0;
					}
					wait(100);
					break;
				case 3:
					if(state_init[0] != 3)
					{
						state_init[0] = 3;
						if(state_init[3] == 0)
							state_init[3] = 1;
						else
							state_init[3] = 0;
					}
					wait(100);
					break;
				case 4:
					if(state_init[0] != 4)
					{
						state_init[0] = 4;
						if(state_init[4] == 0)
							state_init[4] = 1;
						else
							state_init[4] = 0;
					}
					wait(100);
					break;
				default:
					wait(100);
					break;
			}
			if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 0)
				sprintf(string,"LB=0;RB=0;WPER=0");
			else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 0)
				sprintf(string,"LB=1;RB=0;WPER=0");
			else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 0)
				sprintf(string,"LB=0;RB=1;WPER=0");
			else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 0)
				sprintf(string,"LB=1;RB=1;WPER=0");
			else if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 1)
				sprintf(string,"LB=0;RB=0;WPER=1");
			else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 1)
				sprintf(string,"LB=1;RB=0;WPER=1");
			else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 1)
				sprintf(string,"LB=0;RB=1;WPER=1");
			else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 1)
				sprintf(string,"LB=1;RB=1;WPER=1");

			if(state != -1)// && state != 0)
			{
				wait(100);
				WriteLCD(2,string);
			}
		}		
	}
	return 0;
}