}
void display()//显示年、月、日、时间和星期 { uchar temp12; uchar temp11; uchar temp10; uchar temp9; uchar temp8; uchar temp7; uchar temp6; uchar temp5; uchar temp4; uchar temp3; uchar temp2; uchar temp1; lcd_pos(0x02); temp12=num[ng]; lcd_wdat(temp12); lcd_pos(0x03); temp11=num[nd]; lcd_wdat(temp11); lcd_pos(0x05); temp10=num[yg]; lcd_wdat(temp10); lcd_pos(0x06); temp9=num[yd]; lcd_wdat(temp9); lcd_pos(0x08); temp8=num[rg]; lcd_wdat(temp8); lcd_pos(0x09); temp7=num[rd]; lcd_wdat(temp7); lcd_pos(0x0c); switch(week%7) {
case 0:lcd_wstr(\ case 1:lcd_wstr(\ case 2:lcd_wstr(\ case 3:lcd_wstr(\ case 4:lcd_wstr(\ case 5:lcd_wstr(\ case 6:lcd_wstr(\ } lcd_pos(0x44); temp6=num[sg]; lcd_wdat(temp6); lcd_pos(0x45); temp5=num[sd]; lcd_wdat(temp5); lcd_pos(0x047); temp4=num[fg]; lcd_wdat(temp4); lcd_pos(0x48); temp3=num[fd]; lcd_wdat(temp3); lcd_pos(0x4a); temp2=num[mg]; lcd_wdat(temp2); lcd_pos(0x4b); temp1=num[md]; lcd_wdat(temp1); }
void update() //更新时间 { if(sec>59) { min++; sec=0; } if(min>59) { hou++;
min=0; } if(hou>23) { day++; week++; hou=0; } if(day>30) { mon++; year=0; } if(mon>12) { year++; mon=0; } if(year>99) year=0; }
void spit_time() {
ng=(int)year/10; //年的高位 nd=(int)year;// 年的低位 yg=(int)mon/10; //月的高位 yd=(int)mon; // 月的低位 rg=(int)day/10; rd=(int)day; sg=(int)hou/10; sd=(int)hou; fg=(int)min/10; fd=(int)min; mg=(int)sec/10; md=(int)sec; }
void scan() //扫描键盘 { if(setup==0) { delay(1); } if(setup==0) { led=0; if(shi==0) { delay(1); } if(shi==0) { hou++; led=1; shi=1; } if(fen==0) { delay(10); } if(fen==0) { min++; led=1; fen=1; } } }
void Send_pcf8563_byte(uchar bb) //向PCF8563发送一个字节 { uchar aa; pcf8563_scl=0; for(aa=0;aa<8;aa++) { if((bb&0x80)==0x80) { pcf8563_sda=1; } else
{ pcf8563_sda=0; } pcf8563_scl=1; pcf8563_scl=0; bb=bb<<1; } _nop_(); _nop_(); pcf8563_sda=1; pcf8563_scl=1; busy=0; if(pcf8563_sda) { busy=1; } else { _nop_(); _nop_(); pcf8563_scl=0; busy=0; } }
void write_pcf8563(uchar subadd,uchar dat)// 向PCF8563对应地址写数据 { start_pcf8563(); Send_pcf8563_byte(0xa2); if(!busy) { Send_pcf8563_byte(subadd); if(!busy) { Send_pcf8563_byte(dat); } } stop_pcf8563(); }
void read_pcf8563() //读当时的时,分,钞