u16 LCD_GetPoint(u16 x,u16 y)//读取某像素点的颜色值 { u16 pixel=0; Set_Addr(x,y); LCD_Read(); DelayN(2); pixel=LCD_Read(); return pixel; }
/** * Read the busy flag. */ static uint8_t LCD_ReadFlag() { LCD_DataIn(); GPIO_ResetBits(PORT(LCD_CTRL_PORT),LCD_RS); GPIO_SetBits(PORT(LCD_CTRL_PORT),LCD_RW); uint8_t result=0; result=(LCD_Read()<<4); result|=LCD_Read(); return result & LCD_BUSY_FLAG; }
u16 LCD_ReadSta(void) { u16 data; /* Write 16-bit Index, then Write Reg */ SetRs ClrRd SetRd data = LCD_Read(); SetCs return data; }
/******************************************************************************* * Function Name : LCD_ReadReg * Description : Reads the selected LCD Register. * Input : None * Output : None * Return : LCD Register Value. *******************************************************************************/ u16 LCD_ReadReg(u8 LCD_Reg) { u16 data; /* Write 16-bit Index (then Read Reg) */ ClrCs ClrRs ClrWr LCD_Write(LCD_Reg); SetWr /* Read 16-bit Reg */ SetRs ClrRd SetRd data = LCD_Read(); SetCs return data; }
/* void LCD_PrintNumStr(uchar x,uchar y,uchar *s) { x =(x / 8) * 8; while(*s) { LCD_PutImg(x,y,1,11,Num_Tab + (*s - '0') * 11); x = x + 8; s++; } } void LCD_PrintBlackBlock(uchar x,uchar y,bool not_empty) { x =(x / 8) * 8; LCD_PutImg(x,y,1,11,BlockTab + (not_empty?0:1) * 11); } */ void LCD_ReverseRect(uchar x,uchar y,uchar w,uchar h) { uint data addr; uchar data i,j; uchar data c; x =(x / 8) * 8; addr = LCD_GRAPH_HOME_ADDR + LCD_WIDTH * y + x/8; for(j=0;j<h;j++) { for(i=0;i<w;i++) { LCD_WriteInt(addr +i,0x24); LCD_Comm(LC_NOC_RD); c = LCD_Read(); c = ~c; LCD_Write1(c,LC_NOC_WR); } addr += LCD_WIDTH; } }
int main (void) { int loop=0, werbung=0, tnet=-1,blit=0,cnum=-1,tv,wflag=1,runtime=0, mut=0, vol=0, tmin=15; char tstr[40],zapchan[40],msgchan[40]; FILE *fh1; time_t t1,t2,t3,t4; printf("Blockad Version %s\n",P_VERSION); if (!ReadConf()) { printf("Blockad <Configuration failed>\n"); } else { if((fh1=fopen(FLG_FILE,"r"))!=NULL) { if(fgets(zapchan, sizeof(zapchan), fh1)) { Trim_String(zapchan); if(fgets(tstr, sizeof(tstr), fh1)) { sscanf(tstr,"%d",&cnum); if(fgets(tstr, sizeof(tstr), fh1)) { sscanf(tstr,"%d",&rezap); if(fgets(msgchan, sizeof(msgchan), fh1)) { Trim_String(msgchan); } else { sprintf(msgchan,"Unbekannt"); } if(fgets(tstr, sizeof(tstr), fh1)) { if(sscanf(tstr,"%d",&vol)==1) { if(volume) { if(fgets(tstr, sizeof(tstr), fh1)) { if(sscanf(tstr,"%d",&mut)!=1) { mut=0; } } } } } if(fgets(tstr, sizeof(tstr), fh1)) { if(sscanf(tstr,"%d",&tmin)!=1) { tmin=15; } } } } else { rezap=420; } loop=1; if(cnum<0) { inet=-1; } } fclose(fh1); } time(&t1); t4=t3=t1; #ifdef HAVE_DBOX_HARDWARE LCD_Init(); #endif if(inet>=0) { if(Open_Socket()==-1) { inet=-1; } } while(loop) { time(&t2); if(inet>=0) { tnet=-1; if(inet>=0) { tv=Check_Socket(cnum,&werbung); if(!werbung) { if((t2-t4)>tmin) { Do_Rezap(zapchan,vol,mut); loop=0; } } else { t4=t2; } if(tv>=0) { tnet=inet; } } inet=tnet; } if(loop) { if((fh1=fopen(FLG_FILE,"r"))!=NULL) { fclose(fh1); if(inet>=0) { if(wflag) { fh1=fopen(STS_FILE,"w"); fprintf(fh1,"%s\n",msgchan); fprintf(fh1,"Auto\n"); fclose(fh1); wflag=0; } if(t3!=t2) { sprintf(tstr,"%s",(blit^=1)?" ":" WZ"); #ifdef HAVE_DBOX_HARDWARE LCD_Read(); LCD_draw_string(97, 13, tstr); LCD_update(); #endif t3=t2; } sleep(1); } else { runtime=t2-t1; if(runtime>rezap) { Do_Rezap(zapchan,vol,mut); loop=0; } else { if(t3!=t2) { runtime=rezap-runtime; sprintf(tstr,"%2d:%02d",runtime/60,runtime%60); fh1=fopen(STS_FILE,"w"); fprintf(fh1,"%s\n",msgchan); fprintf(fh1,"%s\n",tstr); fclose(fh1); #ifdef HAVE_DBOX_HARDWARE LCD_Read(); LCD_draw_string(81, 13, tstr); LCD_update(); #endif sleep(1); t3=t2; } } } } else { loop=0; } } } } #ifdef HAVE_DBOX_HARDWARE LCD_Close(); #endif if(inet>=0) { Close_Socket(); } sprintf(tstr,"cd /tmp\nrm blockads.*"); system(tstr); return 0; }
u16 Read_ID(void)//读设备ID { Write_COM(0x0000); return LCD_Read(); }