《多功能万年历》word版Word文档下载推荐.docx
《《多功能万年历》word版Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《《多功能万年历》word版Word文档下载推荐.docx(30页珍藏版)》请在冰点文库上搜索。
/****************************************************************/
voiddelay_6us(ucharus)
{
while(us--);
}
voiddelay_1ms(uintms)
uinti,j;
for(i=ms;
i>
0;
i--)
for(j=122;
j>
j--);
voidLCD_Check_Busy()
do
{
LCD_Date=0xff;
E=0;
RS=0;
RW=1;
E=1;
delay_1ms
(1);
}while(LCD_Date&
0x80);
voidLCD_Write_com(ucharwcom)
LCD_Check_Busy();
E=0;
RS=0;
RW=0;
LCD_Date=wcom;
E=1;
delay_1ms
(1);
/*
ucharLCD_Read_date()
RS=1;
RW=1;
delay_1m
(1);
returnLCD_Date;
*/
voidLCD_Write_date(ucharwdate)
LCD_Date=wdate;
voidLCD_Init()
LCD_Write_com(0x38);
LCD_Write_com(0x08);
LCD_Write_com(0x01);
LCD_Write_com(0x02);
LCD_Write_com(0x06);
LCD_Write_com(0x0c);
voidInit_18b20()
DQ=1;
delay_6us
(2);
DQ=0;
delay_6us(100);
delay_6us(50);
voidWrite_18b20(ucharwdate)
uchari;
for(i=0;
i<
8;
i++)
DQ=0;
delay_6us
(2);
DQ=wdate&
0x01;
delay_6us(30);
wdate=wdate>
>
1;
DQ=1;
}
ucharRead_18b20()
uchari,rdate=0;
{
rdate=rdate>
if(DQ==1)
rdate=rdate|0x80;
return(rdate);
voidGet_Temperature()
ucharHigh,Low;
Init_18b20();
Write_18b20(0xcc);
Write_18b20(0x44);
delay_1ms(30);
Write_18b20(0xbe);
Low=Read_18b20();
High=Read_18b20();
Temp_Value=High;
Temp_Value=Temp_Value<
<
Temp_Value=Temp_Value|Low;
if(Temp_Value<
=0x0fff)
Flag=0;
else
Flag=1;
Temp_Value=~Temp_Value+1;
Temp_Value=Temp_Value*0.625+0.5;
voidDisplay_18b20()
ucharBai,Shi,Ge,Point;
Get_Temperature();
delay_6us(10);
Bai=Temp_Value/1000+0x30;
Shi=Temp_Value/100%10+0x30;
Ge=Temp_Value/10%10+0x30;
Point=Temp_Value%10+0x30;
if(Bai==0x30)
Bai=0x20;
if(Shi!
=0x30&
&
Flag==1)
Bai=0x2d;
if(Shi==0x30)
{
if(Flag==0)
Shi=0x20;
else
Shi=0x2d;
}
}
LCD_Write_com(0xc0+9);
LCD_Write_date(Bai);
LCD_Write_date(Shi);
LCD_Write_date(Ge);
LCD_Write_date('
.'
);
LCD_Write_date(Point);
voidWrite_1302_clock(ucharwdate)
clock_clk=0;
clock_dat=wdate&
wdate>
=1;
clock_clk=1;
ucharRead_1302_clock()
rdate>
if(clock_dat==1)
returnrdate;
voidWrite_1302_byte(ucharreg,ucharwdate)
clock_rst=0;
clock_clk=0;
clock_rst=1;
Write_1302_clock(reg);
Write_1302_clock(wdate);
ucharRead_1302_byte(ucharreg2)
ucharrdate;
Write_1302_clock(reg2);
rdate=Read_1302_clock();
voidInit_1302()
Write_1302_byte(0x8e,0x00);
Write_1302_byte(0x80,0x80);
//暂停
Write_1302_byte(0x86,Date);
//date
Write_1302_byte(0x88,Month);
//month
Write_1302_byte(0x8a,Week);
//week
Write_1302_byte(0x8c,Year);
//year
Write_1302_byte(0x84,Hour);
Write_1302_byte(0x82,Min);
Write_1302_byte(0x80,Sec);
Write_1302_byte(0x90,0xa0);
Write_1302_byte(0x8e,0x80);
voidRead_1302()
Week=Read_1302_byte(0x8b);
//day
Hour=Read_1302_byte(0x85);
//hour
Min=Read_1302_byte(0x83);
//min
Sec=Read_1302_byte(0x81);
//sec
Date=Read_1302_byte(0x87);
Month=Read_1302_byte(0x89);
Year=Read_1302_byte(0x8d);
//year
voidDisplay_1302()
ucharl,h;
LCD_Write_com(0x80+0);
if((Flag_1302==1&
Latter>
=N&
Count==2))
if(Latter==N)
Latter=0;
LCD_Write_date(0x20);
h=(Hour>
4)+0x30;
l=(Hour&
0x0f)+0x30;
LCD_Write_date(h);
LCD_Write_date(l);
:
'
Count==1))
h=(Min>
l=(Min&
Count==0))
h=(Sec>
l=(Sec&
LCD_Write_com(0x80+9);
Count==3))
l=(Week&
LCD_Write_com(0xc0+0);
Count==4))
h=(Date>
l=(Date&
/'
Count==5))
h=(Month>
l=(Month&
Count==6))
h=(Year>
l=(Year&
voidDisplay_Speaker()
ucharl_Speaker,h_Speaker;
LCD_Write_com(0x80+11);
if(Flag_Speaker==1)
if(Latter>
Count==2)
if(Latter==N)
{
Latter=0;
}
LCD_Write_date(0x20);
else
h_Speaker=(Hour_Speaker>
l_Speaker=(Hour_Speaker&
LCD_Write_date(h_Speaker);
LCD_Write_date(l_Speaker);
LCD_Write_date('
Count==1)
h_Speaker=(Min_Speaker>
l_Speaker=(Min_Speaker&
if(Flag_Speaker==0)
ucharUp(uchartime)
ucharhigh_up,low_up;
low_up=time&
0x0f;
high_up=time>
4;
low_up++;
if(low_up==10)
low_up=0;
high_up++;
if((high_up==6&
(Count==0||Count==1))||(high_up==10&
high_up=0;
if(high_up==0&
low_up==8&
Count==3)
low_up=1;
high_up<
=4;
time=high_up|low_up;
if(time==0x24&
Count==2&
Flag_1302==1)
time=0;
if(time==0x13&
Count==5)
time=0x01;
if(Count==4&
time==0x32&
(Month==0x01||Month==0x03||Month==0x05||Month==0x07||Month==0x08||Month==0x10||Month==0x12))
time==0x31&
(Month==0x02||Month==0x04||Month==0x06||Month==0x09||Month==0x11))
returntime;
ucharDown(uchartime)
ucharhigh_down,low_down;
low_down=time&
high_down=time>
if(Count==0||Count==1)
if(low_down==0)
low_down=9;
if(high_down==0)
high_down=5;
else
high_down--;
low_down--;
if(Count==2)
{
time=0x23;
gotoloop1;
l