下面是主程序文件预览:
- #include<reg51.h>
- #include"define.h"
- #include"delay.h"
- #include"DS1302.h"
- #include"5110.h"
- #include"key.h"
- #include"dht11.h"
- bit flag1,flag_clock,flag,flag_c,flag7,flag_arm,flag_0=1,flag_1=1,flag_2=1,flag_c0;
- uchar flag_dht;
- uchar year,month,date,day,second,hour,min;
- uchar monthday[]={0,31,0,31,30,31,30,31,31,30,31,30,31};
- uchar *week[]={"SUN","MON","TUS","WEN","THU","FRI","SAT"};
- uchar flag_dis;
- void init_T0(void)
- {
- TMOD = 0x01;
- TH0 = 0x3C;
- TL0 = 0x0B0;
- EA = 1;
- ET0 = 1;
- TR0 = 1;
- }
- void main()
- {
- P1=0XFF;
- _nop_();
- P0=0XFF;
- _nop_();
- P2=0XFF;
- _nop_();
- P3=0X84;
- EX0=1;
- IT0=1;
- delay_ms(1);
- time_init();
- LCD_clear();
- LCD_init();
- init_T0();
- while(1)
- {
- if(flag_n==0)
- {
- delay_ms(10);
- if(flag_n==0)
- {
- while(flag_n==0);
- bl=1;
- flag=0;
- }
- }
- if(flag)
- {
- alarm();
- }
- clock();
- key_scan();
- // changeweek();
- if(flag_display)
- {
- switch(flag_dis){
- case 0:
- if(flag_0){
- LCD_clear();
- flag_2=1;
- flag_0=0;
- }
- LCD_tuan(0,0);
- flag_c0=0;
- break;
- case 1:
- if(flag_1){
- LCD_clear();
- flag_0=1;
- flag_1=0;
- }
- flag_c0=1;
- break;
- case 2:
- if(flag_2){
- LCD_clear();
- changeweek();
- flag_1=1;
- flag_2=0;
- }
- delay(200);
- Get_data();
- other_display();
- flag_c0=0;
- break;
- }
- }
- }
-
- }
- void IN0()interrupt 0
- {
- PCON=0;
- TH0 = 0x3C;
- TL0 = 0x0B0;
- ET0=1;
- TR0=1;
- }
- void TIME0()interrupt 1
- {
- uchar x,y,z;
- TH0 = 0x3C;
- TL0 = 0x0B0;
- TR0=0;
- x++;
- if(x==20){
- y++;
- x=0;
- if(y==5){
- y=0;
- z++;
- flag_dis++;
- if(flag_dis>2){
- flag_dis=0;
- }
- if(z==6)
- {
- z=0;
- bl=0;
- }
- }
- }
- TR0=1;
- }
复制代码 |