基于PIC16F877A的万年历程序
timerinit();//定时器开启
while(1)//主循环
{
//以下为温度处理
if(display_tem)//每1秒刷新一次温度
{
display_tem=0;//标志位归0
convert_T();
delay(250);
read_T();
if(temp1>80) temp1=0;//温度范围规定
if(temp2>15) temp2=0;
write_english(2,72,temp1/10);
write_english(2,80,temp1%10);
write_english(2,88,11); //.
write_english(2,96,tablexiao[temp2]);
write_chinese(2,104,18); //℃
}
//以下为日期刷新
if(display_time) //每过1 秒,进入此函数刷新时间
{
display_time=0;//标志位归0
convert_T();
Get1302(timebuf);
//以下为公历转农历moon[0]记录年,moon[1]记录月,moon[2]记录日
m_temp[0]=(timebuf[6]>>4)*10+timebuf[6]&0x0f;//公历日期 十六进制转十进制
m_temp[1]=(timebuf[4]>>4)*10+timebuf[4]&0x0f;
t=(timebuf[3]>>4)*10;
k= timebuf[3]&0x0f;
m_temp[2]=t+k;
data_cvt(m_temp[0],m_temp[1],m_temp[2],& moon[0]);//公历转农历函数调用
//以下为显示公历日期
write_english(0,4,2); //20xx年
write_english(0,12,0);
write_english(0,20,(timebuf[6]>>4)&0x0f);
write_english(0,28,timebuf[6]&0x0f);
write_chinese(0,40,0);
write_english(2,0,(timebuf[4]>>4)&0x01);//xx月
write_english(2,8,timebuf[4]&0x0f);
write_chinese(4,0,1);
write_english(3,24,(timebuf[3]>>4)); //xx日
write_english(3,32,timebuf[3]&0x0f);
write_chinese(3,40,16);
write_chinese(6,4,2);//星期x
write_chinese(6,20,3);
write_chinese(6,36,(timebuf[5]&0x07)+2);
//以下为农历日期显示
write_chinese(4,64,moon[1]+3); //显示月份,在一到十就显示相应数字,十一用廿,十二用腊表示
write_chinese(4,80,1);//“月”
//以下为农历日的处理
switch(moon[2]/10)//判断农历日十位为:初,十,廿,三
{case 0:write_chinese(4,96,17);break;
case 1:write_chinese(4,96,13);break;
case 2:write_chinese(4,96,19);break;
case 3:write_chinese(4,96,6);break;
}
if (moon[2]%10==0)//农历日为整十,则相应个位不能显示为零,而因该显示为十,比如:三十
write_chinese(4,112,13);
else
write_chinese(4,112,3+moon[2]%10);
write_english(0,64,(timebuf[2]>>4)&0x03); //时分秒显示
write_english(0,72,timebuf[2]&0x0f);
write_english(0,80,10); //:
write_english(0,88,(timebuf[1]>>4)&0x0f);
write_english(0,96,timebuf[1]&0x0f);
write_english(0,104,10); //:
write_english(0,112,(timebuf[0]>>4)&0x0f);
write_english(0,120,timebuf[0]&0x0f);
}
}
}
PIC16F877A万年历程 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)