#include #include int main() { int key,i,i7053_flag; char i7053_data[20]; uint i7053_di=0,i7053_di_old=0x1234; long timevalue; InitLib(); InitLCD(); TimerOpen(); InstallCom2(9600L,8,0,1); timevalue = GetTimeTicks()+300; TextOutAt(1,1,"I-87053"); TextOutAt(1,2,"0123456789ABCDEF"); while(1) { if(Kbhit()) { key=Getch(); if(key=='Q')break; } while(IsCom2()) { i7053_data[i7053_flag] = ReadCom_2(); if(i7053_data[0] == '>') { if(i7053_data[5] == 0x0d) { //show data on LCD i7053_di=(((unsigned)(ascii_to_hex(i7053_data[1]))<<12)&0xF000) +((ascii_to_hex(i7053_data[2])<<8)&0xF00) +((ascii_to_hex(i7053_data[3])<<4)&0xF0) +(ascii_to_hex(i7053_data[4])&0xF); } i7053_flag++; if(i7053_flag > 5) { i7053_flag = 0; i7053_data[0] = 0; i7053_data[5] = 0; } } } if(i7053_di != i7053_di_old) { for(i = 0 ; i < 16 ; i++) { lamp(1+i,3,(i7053_di>>i)&0x1); } i7053_di_old = i7053_di; } if(timevalue < GetTimeTicks()) { ClearCom2(); ToCom2('@'); //@01 : @ is command ,01 : is address ToCom2('0'); //@01 : @ is command ,01 : is address ToCom2('1'); //@01 : @ is command ,01 : is address ToCom2(0x0d); //@01 : @ is command ,01 : is address timevalue = GetTimeTicks()+300; i7053_flag = 0; } } RestoreCom2(); CloseLCD(); return 0; }