状态栏下面的计时是按学校时刻表下一个节点倒计时,比如下课倒计时,上课倒计时,起床倒计时,晚饭倒计时等
单片机源程序如下:- #include"head.h"
- main()
- {
- oled_init1();//初始化OLED屏
- //oled_dis2(32,0,16,2,4073);
- //oled_dis2(48,0,16,2,4105);
- //oled_dis2(64,0,16,2,4137);
- //oled_dis2(80,0,16,2,4169);
- while(!P36);//等待射频芯片初始化
- uart_init1();//初始化串口通讯
- ds1302_init();//初始化实时时钟
- key_init();//使能按键
- adc_get2();//获取电源电压
- //if(adc_c<20)//低电量处理
- //{
- //ES=0;
- //IT0 = 1; //设置INT0的中断类型:仅下降沿
- //EX0 = 1; //使能INT0中断
- //while(adc_c<30)
- //{
- //gsm_off();
- //EX0 = 1; //使能INT0中断
- //oled_off();
- //PCON = 0x02;
- //oled_on();
- //adc_get2();
- //}
- //ES=1;
- //}
- gsm_init();//移动电话初始化
- oled_fill1(0x00);//清屏
- ds1302_read();//读取时间
- down_time();//高考倒计时计算
- while(1)
- {
- //if((!ring)&&(fun!=10))//有电话打入时
- //{
- //cfun=fun;
- //fun=10;
- //enter1(fun);
- //}
- if(lock)
- {
- if(enter){PCON |= 0x02;delayms(1);}
- else
- {
- enter=1;
- IT0 = 1; //设置INT0的中断类型:仅下降沿
- EX0 = 1; //使能INT0中断
- EA=1;
- oled_off();
- ES=0;
- kp=1;
- //PCON |= 0x02;
- delayms(1);
- }
- }
- else
- {
- if(enter)
- {
- ds1302_work();//时钟驱动
- uart_work();//串口驱动
- key_scan();//按键驱动
- if(time5)
- {
- mark_tim();//学校时刻表计算
- adc_get2();//刷新电量
- oled_dis8();//状态栏
- if(flag_h) //我的计时
- {time_h++;}
- if(flag_w) //同桌计时
- {time_w++;}
- if(flag_h||flag_w)//计时时防止关机
- {offt=0;}
- }
- if(time8){down_time();}//高考倒计时更新
- if(close_time==5)//关机时间延长
- {
- if(k01||k11||k21)
- {close_time=60;}
- }
- switch(fun)
- {
- case 0:fun0();break;
- case 1:fun1();break;
- case 2:fun2();break;
- case 3:fun3();break;
- case 4:fun4();break;
- case 5:fun5();break;
- case 10:fun10();break;
- default :fun=0;break;
- }
- //if(fun==0){fun0();}
- //else if(fun==1){fun1();}
- //else if(fun==2){fun2();}
- //else if(fun==3){fun3();}
- //else if(fun==4){fun4();}
- //else if(fun==5){fun5();}
- //else if(fun==10){fun10();}
- if(kp){sys_lock();}
- }
- else
- {oled_init1();oled_fill1(0x00);enter=1;EX0 = 0;ds1302_read();down_time();adc_get2();mark_tim();oled_dis8();enter1(fun);close_time=5;offt=0;ES=1;}
- if(time5)
- {
- offt++;
- if(ring==0)
- {
- offt=0;
- }
- if(offt>close_time)
- {
- offt=0;
- sys_lock();
- }
- }
- }
- if(com&&(fun!=10))
- {
- cfun=fun;
- fun=10;
- enter1(fun);
- }
- //结尾游历/////////////////////////////////////////////////////////////////////////////////////////////////////////////
- if(k01){k01=0;}
- if(k11){k11=0;}
- if(k21){k21=0;}
- if(k02){k02=0;}
- if(k12){k12=0;}
- if(k22){k22=0;}
- if(k03){k03=0;}
- if(k13){k13=0;}
- if(k23){k23=0;}
- if(!P30){IAP_CONTR = 0x60;}
- if(time5){time5=0;}
- if(time8){time8=0;}
- }
- }
复制代码
|