#include "reg52.h"
#include "macroconst.h"
#include "keyscan.h"
#include "screen.h"
#include "18b20.h"
#include "ds1302.h"
#include "atao_12864.h"
#include "24c02.h"
idata unsigned char state1[1];
unsigned char screennum=1;//屏幕号
#define time_task_sec 200 //节拍200Hz
#define clock 24000000 //晶振
#define max_task 4 //最大任务数
idata unsigned char task_delay[4];
#define task_delay0 time_task_sec/1 //2赫兹18b20
#define task_delay1 time_task_sec/5 //10赫兹屏幕
#define task_delay2 time_task_sec/3 //4赫兹1302
#define task_delay3 time_task_sec/20 //20赫兹键盘
void init()
{
unsigned char i;
init18b20();
ds1302_init();
initina1(); //---------------------------LCD字库初始化程序
RdFromROM(state1,8,1);
state[0]=state1[0]; //-------界面
RdFromROM(state1,15,1);
state[1]=state1[0];//------- 闹钟
RdFromROM(state1,11,1);
key_sound=state1[0];//-------按键音
// state[2]=state1[2];
// state[3]=state1[3];
screennum=1;//------默认一号屏
for(i=0;i<max_task;i++)//清除任务延时
{task_delay[i]=0;}
TMOD=0x11;
EA=1;
TH0=255-clock/time_task_sec/12/526;
TL0=255-clock/time_task_sec/12%526;
ET0=1;
TR0=1;
}
void main()
{
init();
while(1)
{ if(task_delay[0]==0){readtemp(); task_delay[0]=task_delay0;}
if(task_delay[3]==0){MenuCheckKey(); task_delay[3]=task_delay1;}
if(task_delay[1]==0){screen_select(screennum);task_delay[1]=task_delay1;}
if(task_delay[2]==0){ds1302_read_time(); task_delay[2]=task_delay0;}
}
}
void timer0() interrupt 1
{
uchar i=0;
TH0=255-clock/time_task_sec/12/526;
TH1=255-clock/time_task_sec/12%526;
for(i=0;i<max_task;i++)if(task_delay[i]) task_delay[i]--; // miao=21,fen=33,xiaomiao=94;
if(ma_start==1)
{
tt++;
if(tt==8)
{
tt=0;xiaomiao++;
if(xiaomiao==99)
{
xiaomiao=0;miao++;
if(miao==60)
{
miao=0;fen++;
if(fen==99)
{
fen=0;
}
}
}
}
}
}
|