BYTE MakeConversionTable(BYTE RowKeyCode); //converting keykode from keyboard to PC format BYTE CoverKey(BYTE GetKeyCode); BYTE DCoverKey(BYTE GetCKeyCode); BYTE keycode[8] = {0, 0, 0, 0, 0, 0, 0, 0}; //keykode array which we write to USB. 3 byte is Keykode, 0 - modifier /////////////////////////////////////////////////////////////////////////////////////////////////
int i,j,k,f_t,loop,loop1,loop2,temp_loop=0,send_bit;
BYTE Ack=0; BYTE WeiZhi=0; ///////////////////////////////////////////////////////////////////////////////////////// /* setup a 2 byte I2C buffer */ //BYTE rxBuffer[2] = {0xFF, 0x00}; //BYTE i = 0; BYTE Key; BYTE CKey; BYTE OldKey; //////////////////// //char tab0[]={0xCC,0XEC,0XBD,0XF2,0xbf,0xc2,0xb6,0xd9}; //tian jin ke dun //char tab0[]={0xD1 ,0xAA ,0xD1 ,0xB9 ,0xBC ,0xC6 ,0xCA ,0xE4 ,0xC8 ,0xEB ,0xBC ,0xFC ,0xC5 ,0xCC};
char tab0[]={0xB1,0xEA,0xD7,0xBC ,0xCA ,0xE4 ,0xC8 ,0xEB ,0xBC ,0xFC ,0xC5 ,0xCC};//shu ru jian pan char tab1[]={0x57,0x61,0x69,0x74,0x20,0x46,0x6f,0x72,0x20,0x50,0x63};//Wiat For Pc char tab2[]={0x47,0x65,0x74,0x20,0x50,0x63,0x20,0x4e,0x6f,0x77,}; //Get PC Now char tab3[]={0x20,0x46,0x6c,0x75,0x78,0x3a}; //Flux char tab4[]={0x20,0x54,0x65,0x6d,0x70,0x3a}; //Temp char tab5[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};//0123456789 char tab6[]={0x20,0x20,0x73,0x63,0x63,0x6d}; //sccm char tab7[]={0x20,0x20,0x20,0x20,0x27,0x43}; //temp unit
void delay() { int j; for(i=0;i<100;i++) {for(j=0;j<100;j++) ; } }
void chk_busy() //judge the LCD busy? { PRT4DR=0X0FF; LED_1_Switch(0); LED_2_Switch(1); LED_3_Switch(1); //for(i=0;i<1000;i++) ; while((PRT4DR&0X80)!=0); LED_3_Switch(0); }
void send_instruction(char data) { chk_busy(); LED_1_Switch(0); LED_2_Switch(0); PRT4DR=data; LED_3_Switch(1); LED_3_Switch(0); }
void send_data(char data) { chk_busy(); LED_1_Switch(1); LED_2_Switch(0); PRT4DR=data; LED_3_Switch(1); LED_3_Switch(0); }
void Lclear() { send_instruction(0x30); for(i=0;i<100;i++) ; send_instruction(0x01); for(i=0;i<100;i++) ; send_instruction(0x03); for(i=0;i<100;i++) ; send_instruction(0x06); for(i=0;i<100;i++) ; send_instruction(0x0e); for(i=0;i<100;i++) ; }
void initi() { LED_1_Start(); LED_2_Start(); LED_3_Start(); LED_4_Start(); LED_4_Switch(0); delay(); delay(); LED_4_Switch(1);
chk_busy();
send_instruction(0x30); for(i=0;i<100;i++) ; send_instruction(0x01); for(i=0;i<100;i++) ; send_instruction(0x03); for(i=0;i<100;i++) ; send_instruction(0x06); for(i=0;i<100;i++) ; send_instruction(0x0e); for(i=0;i<100;i++) ;
send_instruction(0x91); //biao jun shu ru jian pan for(i=0;i<100;i++) ; for(k=0;k<12;k++) { send_data(tab0[k]); for(i=0;i<100;i++) ; } send_instruction(0x89); //shu ru jian pan for(i=0;i<100;i++) ; for(k=0;k<11;k++) { send_data(tab1[k]); for(i=0;i<100;i++) ; } }///////////////////////////////////////////////
void main(void) { initi(); M8C_EnableGInt; USBFS_Start(0, USB_5V_OPERATION); //Start USBFS Operation using device 0 and with 5V operation while(1) { while (!USBFS_bGetConfiguration())//Wait for Device to enumerate USBFS_LoadInEP(1, keycode, 8, USB_NO_TOGGLE); Lclear(); //display Get Pc Now! send_instruction(0x81); //shu ru jian pan for(i=0;i<100;i++); for(k=0;k<11;k++) { send_data(tab2[k]); for(i=0;i<100;i++) ; } // send_instruction(0x88); while(1) { while(!USBFS_bGetEPAckState(1)); //Wait for ACK before loading data USBFS_LoadInEP(1, keycode, 8, USB_TOGGLE); Key=CoverKey(bReadKeypad()); //get key CKey=DCoverKey(Key); //cover key to lcd //---------------------------- //send the originality num send_instruction(0x88); // send_data(Key); // for(i=0;i<100;i++); //----------------------------// send num to lcd can display CKey=DCoverKey(Key); send_data(CKey); for(i=0;i<100;i++); keycode[2] = Key; } } }
|