本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
求高手帮加个阴历的程序上去 见网上多数都是12864显示的,都没见有1602的。请高手帮我在我这个基础上加个阴历部分上去 原来有个温度部分 现在想把温度部分改成阴历的
在这先谢谢了
部分程序如下:
#include<reg51.h>
#include<1602.h>
#include<ds1302.h>
#define uchar unsigned char
#define uint unsigned int
//**************定义按键**************
sbit key1=P3^0;
sbit key2=P3^1;
sbit key3=P3^2;
sbit key4=P3^3;
sbit key5=P3^4;
sbit key6=P3^5;
sbit key7=P3^6;
sbit key8=P3^7;
uchar tt,aa[4];
uint fuhao=0;
uchar xiaoshi,fen,miao,xingqi,nian,yue,ri;
//uchar code shijian[]={nian,yue,ri,xingqi,xiaoshi,fen,miao};
void show_ds1302()
{
nian=read_1bit(0x8d);//读
yue=read_1bit(0x89);
ri=read_1bit(0x87);
xingqi=read_1bit(0x8b);
xiaoshi=read_1bit(0x85);
fen=read_1bit(0x83);
miao=read_1bit(0x81);
//***********时、分、秒*****************
write_com_1602(0x80+0x40); //写
write_data_1602((xiaoshi>>4)+'0');//十位
write_data_1602((xiaoshi&0x0f)+'0');//个位
write_data_1602(':');
write_data_1602((fen>>4)+'0');
write_data_1602((fen&0x0f)+'0');
write_data_1602(':');
write_data_1602((miao>>4)+'0');
write_data_1602((miao&0x0f)+'0');
//**********年、月、日、星期**************
write_com_1602(0x80);
write_data_1602('2');
write_data_1602('0');
write_data_1602((nian>>4)+'0');
write_data_1602((nian&0x0f)+'0');
write_data_1602('-');
write_data_1602((yue>>4)+'0');
write_data_1602((yue&0x0f)+'0');
write_data_1602('-');
write_data_1602((ri>>4)+'0');
write_data_1602((ri&0x0f)+'0');
write_data_1602(' ');
write_data_1602('w');
write_data_1602('e');
write_data_1602('e');
write_data_1602('k');
write_data_1602(xingqi+'0');
}
main()
{
init_1602();
reset_1302();
while(1)
{
if(key1==0)
{
while(key1==0);
fuhao++;
write_com_1602(0x0f);//光标调出
if(fuhao==8) //可调位数
{
fuhao=0;
write_com_1602(0x0c);//关闭光标
}
}
if(fuhao==0)//显示
{
show_ds18b20();
show_ds1302();
}
else if (fuhao==1)
{
write_com_1602(0x80+0x40+1);
if(key2==0)
{
while(key2==0);//加运算
write_1bit(0x8e,0x00);//取消保护
xiaoshi=xiaoshi+1;//小时的加
if((xiaoshi&0x0f)==0x0a)
{
xiaoshi=xiaoshi+0x10;
xiaoshi=xiaoshi&0xf0;
}
if(xiaoshi==0x24) xiaoshi=0;
write_1bit(0x84,xiaoshi);//小时的加
write_com_1602(0x80+0x40); //移位
write_data_1602((xiaoshi>>4)+'0'); // 写小时的十位
write_data_1602((xiaoshi&0x0f)+'0'); // 写小时的个位
write_com_1602(0x80+0x40+1);
write_1bit(0x8e,0x80);//保护
}
if(key3==0)//减运算
{
while(key3==0);
write_1bit(0x8e,0x00);//取消保护
xiaoshi=xiaoshi-1;//小时的减
if((xiaoshi&0x0f)==0x0f)
{
xiaoshi=xiaoshi-0x10;
xiaoshi=xiaoshi&0x09;
}
if(xiaoshi==0x00) xiaoshi=0x24;
write_1bit(0x84,xiaoshi);//小时的减
write_com_1602(0x80+0x40); //移位
write_data_1602((xiaoshi>>4)+'0'); // 写小时的十位
write_data_1602((xiaoshi&0x0f)+'0'); // 写小时的个位
write_com_1602(0x80+0x40+1);
write_1bit(0x8e,0x80);//保护
}
} |