/南阳理工学院
//网站:proteus.5d6d.com
//12864+图形温度计+ds1302+ds18b20+矩阵键盘
//此程序如果要在硬件电路上实现要改一些地方!
//不曾努力,就没有资格说失败!
#include "ds18b20.h"
#include "12864.h"
#include "1302.h"
#include "key.h"
#include "zifu.h"
bit flagg=0;
uchar ip;
main()
{
uchar i;
systemtime realtime;
choose12864(2);
init12864();
clear12864();
play8(0,0,0,shu2); //屏,列,页,地址
play8(0,1,0,shu0);
play16(0,4,0,nian);
play16(1,0,0,yue);
play16(1,4,0,ri);
play16(0,2,1,shi);
play16(0,6,1,fen);
play16(1,2,1,miao);
play16(1,0,2,xing);
play16(1,2,2,qi);
vertical(3,63,63);
vertical(3,63,62);
vertical(3,63,58);
vertical(3,63,57);
for(i=0;i<7;i++)
{
dot(57+i,3);
dot(57+i,63);
}
for(i=0;i<12;i++)
{
dot(59,8+5*i);
}
for(i=0;i<7;i++)
{
if(i<4)
{
play16(0,i*2,3,ming+i*32);
}
if(i>=4)
{
play16(1,(i-4)*2,3,ming+i*32);
}
}
init_ds1302();
init_time();
do
{
gettime(&realtime);
play8(0,2,0,(shu0+16*datastring[0]));
play8(0,3,0,(shu0+16*datastring[1]));
play8(0,6,0,(shu0+16*datastring[2]));
play8(0,7,0,(shu0+16*datastring[3]));
play8(1,2,0,(shu0+16*datastring[4]));
play8(1,3,0,(shu0+16*datastring[5]));
play8(0,0,1,(shu0+16*datastring[6]));
play8(0,1,1,(shu0+16*datastring[7]));
play8(0,4,1,(shu0+16*datastring[8]));
play8(0,5,1,(shu0+16*datastring[9]));
play8(1,0,1,(shu0+16*datastring[10]));
play8(1,1,1,(shu0+16*datastring[11]));
play16(1,4,2,(yi+32*(datastring[12]-1)));
gettemperature();
if(flag)
{
play8(0,0,2,fu);
play8(1,6,3,fu);
}
else
{
clear8(6,4,0);
play8(1,6,3,zheng);
}
play8(0,4+flag,2,dian);
play8(0,5+flag,2,C);
play8(0,0+flag,2,(shu0+16*temp[0]));
play8(0,1+flag,2,(shu0+16*temp[1]));
play8(0,2+flag,2,xiao);
play8(0,3+flag,2,(shu0+16*temp[2]));
change();
keyscan();
switch(sum)
{
case 0:ip=ds1302_year;flagg=1;break;
case 1:ip=ds1302_month;flagg=1;break;
case 2:ip=ds1302_week;flagg=1;break;
case 3:ip=ds1302_day;flagg=1;break;
case 4:ip=ds1302_hour;flagg=1;break;
case 5:ip=ds1302_minute;flagg=1;break;
case 6:ip=ds1302_second;flag=1;break;
default:break;
}
if(flagg==1)
{
keyscan();
if(sum==7)
{
set(ip,1);
sum=0xff;;
}
else if(sum==8)
{
set(ip,0);
sum=0xff;
}
}
}
while(1);
}
|