// Function is called to write the chosen text on the System Log. // When a new text is written to the first row,all the old one is lowered down by a row. void Write_Log(char *event) { char hour[4],min[4],day[4],mon[4],year[7]; strcpy(Label105.Caption,Label104.Caption); strcpy(Label104.Caption,Label67.Caption); strcpy(Label67.Caption,Label66.Caption); strcpy(Label66.Caption,Label65.Caption); strcpy(Label65.Caption,Label64.Caption); strcpy(Label64.Caption,Label63.Caption); strcpy(Label63.Caption,Label62.Caption); ByteToStr(datum2.hour,hour); strcpy(Label62.Caption,hour); strcat(Label62.Caption," :"); ByteToStr(datum2.min,min); strcat(Label62.Caption,min); strcat(Label62.Caption," "); ByteToStr(datum2.day,day); strcat(Label62.Caption,day); strcat(Label62.Caption,"."); ByteToStr(datum2.mon,mon); strcat(Label62.Caption,mon); strcat(Label62.Caption,"."); IntToStr(datum2.year,year); strcat(Label62.Caption,year); strcat(Label62.Caption,". "); strcat(Label62.Caption,event); strcpy(Label16.Caption,"Events Up!"); }
void Button44OnClick() { if(tim[0]==1 && tim[1]==1 && tim[2]==1 && tim[3]==1 && tim[4]==1 && datum.hour<24 && datum.min<60 && datum.day<32 && datum.mon<13){ datum2=datum; ByteToStr(datum2.hour,Label73.Caption); ByteToStr(datum2.min,Label75.Caption); ByteToStr(datum2.day,Label76.Caption); strcat(Label76.Caption,"."); ByteToStr(datum2.mon,Label77.Caption); strcat(Label77.Caption,"."); IntToStr(datum2.year,Label78.Caption); strcat(Label78.Caption,"."); } }
void SF_mem() { unsigned char i,l,cnt[4]; long adr=0x111111; for(i=0;i<6;i++) { SerialFlash_WriteByte(arm[i],adr); adr+=0x000020; } strcpy(Label24.Caption," ******"); DrawScreen(&System_Log_Screen); for(l=0;l<10;l++) { ByteToStr(10-l,cnt); strcpy(Label25.Caption," "); strcat(Label25.Caption,cnt); DrawScreen(&System_Log_Screen); FT812_Sound_SetAndPlay(_FT812_SOUND_CLICK,_FT812_SOUND_PITCH_B3,vol); Delay_ms(1000); } Box30.Color=0x00FF0000; Box36.Color=0x00FF0000; Image65.Visible=0; Image66.Visible=1; strcpy(Label25.Caption," ARMED"); strcpy(Label8.Caption," ARMED"); }
// khi het xay ra loi tren may // neu layer = 0 <==> da het tat ca san pham tren ca 3 layer void PC_SendErrorCode(uint8_t code) { uint8_t data[sizeof("ERROR")+2]; memcpy(data, "ERROR", sizeof("ERROR")-1); ByteToStr(&data[sizeof("ERROR")-1], code); USART1_SendPacked(data, sizeof("ERROR")-1+2); }
void Display_BatteryLevel() { char txt[3]; ByteToStr(batt_level,txt); TFT_Set_Pen(CL_WHITE, 10); TFT_Set_Brush(1, CL_WHITE, 0, 0, 0, 0); TFT_Rectangle(150,100,230,115); TFT_Write_Text(txt,150,100); TFT_Write_Char(0x25,180,100); }
void clockReload(void) { if(lcdIsOn==1) { char hour[4]; char minute[4]; char second[4]; lcdCmd(0x80);///カーソルを先頭に移動 ByteToStr(h,hour); if(h<10) { hour[1]='0'; } lcd_str(1,hour); ByteToStr(m,minute); if(m<10) { minute[1]='0'; } minute[0]=':'; lcd_str(0,minute); ByteToStr(s,second); if(s<10) { second[1]='0'; } second[0]=':'; lcd_str(0,second); if(mode==1) { ///lcd_str_byCode(0x5E);0x5E 上向き矢印 lcdCmd(0xC0);///カーソルを2行目の先頭に移動 if(mode1At==0) { lcd_str(0," "); lcd_str_byCode(0x5E); } else if(mode1At==1) { lcd_str(0," "); lcd_str_byCode(0x5E); lcd_str(0," "); } else if(mode1At==2) { lcd_str(0," "); lcd_str_byCode(0x5E); lcd_str(0," "); } } } }
void stopWatchReload(void) { char min[4]; char sec[4]; char down[4]; if(swMode==1) { if(sw_down==99) { if(sw_sec==59) { if(sw_min==59) { } else { sw_down=0; sw_sec=0; sw_min++; } } else { sw_down=0; sw_sec++; } } else { sw_down++; } } lcdCmd(0x80);///カーソルを先頭に移動 ByteToStr(sw_min,min); if(sw_min<10) { min[1]='0'; } lcd_str(1,min); ByteToStr(sw_sec,sec); if(sw_sec<10) { sec[1]='0'; } sec[0]=':'; lcd_str(0,sec); ByteToStr(sw_down,down); if(sw_down<10) { down[1]='0'; } down[0]='.'; lcd_str(0,down); }
void main() { I2C0_Init_Advanced(400000, &_GPIO_Module_I2C0_PD8_9); delay_ms(200); screen_init(); MAX44000_Init(); while(1){ ProxiValue = MAX44000_ReadRegister(PROX); ByteToStr(ProxiValue,Distance); value = (76-( ProxiValue / 3)); OLED_DrawBox (10, 76, value, 3, OLED_COLOR_RED); if(ProxiOldValue != ProxiValue){ OLED_DrawBox (10, 76, 76, 3, OLED_COLOR_WHITE); OLED_DrawBox (10, 76, value, 3, OLED_COLOR_RED); delay_ms(50); } ProxiOldValue = ProxiValue; } }
// Function is called by main to perform change on Home screen if Enable_Home_Change allowed it. void Home_Change() { if(k==0) return; if(k==1) { ero+=TIMER_READ_LS; srand((unsigned)ero); num=rand()%20+1; switch(num) { case 1: Label9.Font_Color=0x0000FFFF; Label10.Font_Color=0x0000FFFF; Box14.Color=0x00400080; Box15.Color=0x00400080; Box14.Color=0x00400080; Box15.Color=0x00400080; Image9.Visible=0; Image16.Visible=0; Image29.Visible=1; Image30.Visible=1; if(hom==1) DrawScreen(&Home); break; case 2: Label11.Font_Color=0x0000FFFF; Box16.Color=0x00400080; Image17.Visible=0; Image31.Visible=1; if(hom==1) DrawScreen(&Home); break; case 3: break; case 4: break; case 5: Box13.Color=0x00400080; Label7.Font_Color=0x0000FFFF; Label8.Font_Color=0x0000FFFF; Image6.Visible=0; Image35.Visible=1; if(hom==1) DrawScreen(&Home); break; case 6: Box3.Color=0x00C0C0C0; Label36.Font_Color=0x00000000; Image10.Visible=0; Image21.Visible=1; if(hom==1) DrawScreen(&Home); break; case 7: break; case 8: Box5.Color=0x00C0C0C0; Label38.Font_Color=0x00000000; Image12.Visible=0; Image23.Visible=1; if(hom==1) DrawScreen(&Home); break; case 9: break; case 10: Box7.Color=0x00C0C0C0; Label40.Font_Color=0x00000000; Image14.Visible=0; Image25.Visible=1; if(hom==1) DrawScreen(&Home); break; case 11: break; case 12: Label5.Font_Color=0x00000000; Box12.Color=0x00C0C0C0; Image1.Visible=0; Image27.Visible=1; if(hom==1) DrawScreen(&Home); break; case 14: Box20.Color=0x00FF4000; Image7.Visible=0; Image36.Visible=1; if(hom==1) DrawScreen(&Home); break; case 15: Box21.Color=0x00008080; Image8.Visible=0; Image37.Visible=1; if(hom==1) DrawScreen(&Home); break; case 16: Box28.Color=0x00800000; if(hom==1) DrawScreen(&Home); break; case 17: Box34.Color=0x00000080; Image3.Visible=0; Image38.Visible=1; Image45.Visible=0; Image64.Visible=1; Image41.Visible=0; Image75.Visible=1; Image44.Visible=0; Image76.Visible=1; if(hom==1) DrawScreen(&Home); break; default: Label5.Font_Color=0x00FFFFFF; Label7.Font_Color=0x00FFFFFF; Label8.Font_Color=0x00FFFFFF; Label9.Font_Color=0x00FFFFFF; Label10.Font_Color=0x00FFFFFF; Label11.Font_Color=0x00FFFFFF; Label36.Font_Color=0x00FFFFFF; Label38.Font_Color=0x00FFFFFF; Label40.Font_Color=0x00FFFFFF; Box3.Color=0x00808080; Box5.Color=0x00808080; Box7.Color=0x00808080; Box12.Color=0x00808080; Box13.Color=0x008000FF; Box14.Color=0x008000FF; Box15.Color=0x008000FF; Box16.Color=0x008000FF; Box20.Color=0x00FF8000; Box21.Color=0x00008040; Box28.Color=0x00FF0000; Box34.Color=0x000000FF; Image1.Visible=1; Image3.Visible=1; Image6.Visible=1; Image7.Visible=1; Image8.Visible=1; Image9.Visible=1; Image10.Visible=1; Image12.Visible=1; Image14.Visible=1; Image16.Visible=1; Image17.Visible=1; Image41.Visible=1; Image44.Visible=1; Image45.Visible=1; Image21.Visible=0; Image23.Visible=0; Image25.Visible=0; Image27.Visible=0; Image29.Visible=0; Image30.Visible=0; Image31.Visible=0; Image35.Visible=0; Image36.Visible=0; Image37.Visible=0; Image38.Visible=0; Image64.Visible=0; Image75.Visible=0; Image76.Visible=0; if(hom==1) DrawScreen(&Home); } if(num<17) num++; else num=0; if(kk>=24) { datum2.min++; if(datum2.min==60) { datum2.min=0; datum2.hour++; if(datum2.hour==24) { datum2.hour=0; datum2.day++; if((datum2.day==30 && datum2.mon==2 && datum2.year%4==0)|| (datum2.day==29 && datum2.mon==2 && datum2.year%4!=0)|| (datum2.day==31 && (datum2.mon==4 || datum2.mon==6 || datum2.mon==9 || datum2.mon==11))|| (datum2.day==32 && (datum2.mon==1 || datum2.mon==3 || datum2.mon==5 || datum2.mon==7 || datum2.mon==8 || datum2.mon==10 || datum2.mon==12))) { datum2.day=1; datum2.mon++; if(datum2.mon>12) { datum2.mon=1; datum2.year++; } } } } kk=0; ByteToStr(datum2.hour,Label73.Caption); ByteToStr(datum2.min,Label75.Caption); ByteToStr(datum2.day,Label76.Caption); strcat(Label76.Caption,"."); ByteToStr(datum2.mon,Label77.Caption); strcat(Label77.Caption,"."); IntToStr(datum2.year,Label78.Caption); strcat(Label78.Caption,"."); } k=0; } }
void SF_rem() { unsigned char i,temp[6]; char txte[4],txtex[4]; int val=0; long adr=0x111111; for(i=0;i<6;i++) { temp[i] = SerialFlash_ReadByte(adr); ByteToStr(temp[i],txte); ByteToStr(arm[i],txtex); if(temp[i]!=arm[i]) val=1; adr+=0x000020; } Delay_ms(3000); for(i=0;i<6;i++) arm[i]=0; strcpy(Label24.Caption,""); DrawScreen(&System_Log_Screen); if(val==0) { a=0; Box30.Color=0x00008040; Box36.Color=0x00008040; Image65.Visible=1; Image66.Visible=0; strcpy(Label25.Caption,"DISARMED"); strcpy(Label8.Caption,"DISARMED"); } }