需要根据题目挖掘有多个界面的处理,中断服务函数中的间隔采集处理,led的闪烁 利用标志位来打开和进行闪烁
#include <STC15F2K60S2.H>
#include "absacc.h"
#include "ds1302.h"
#include "intrins.h"
#include "onewire.h"
sbit S7=P3^0;
sbit S6=P3^1;
sbit S5=P3^2;
sbit S4=P3^3;
bit flag=0,LED_kai=0;
unsigned char yi,er,san,si,wu,liu,qi,ba;
unsigned char code smgduan[18] =
{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0xbf,0xff};
extern unsigned char Timer[7];
unsigned char Temp[10];
unsigned char yemian=0,jiange=1,wendu,T=0;
void InitSystem()
{
XBYTE[0xa000]=0x00;
XBYTE[0x8000]=0xff;
XBYTE[0xc000]=0xff;
XBYTE[0xe000]=0xff;
}
void Delay1ms() //@11.0592MHz
{
unsigned char i, j;
_nop_();
_nop_();
_nop_();
i = 11;
j = 190;
do
{
while (--j);
} while (--i);
}
void Display1(unsigned char yi,unsigned char er)
{
XBYTE[0xc000]=0x01;
XBYTE[0xe000]=smgduan[yi];
Delay1ms();
XBYTE[0xc000]=0x02;
XBYTE[0xe000]=smgduan[er];
Delay1ms();
}
void Display2(unsigned char san,unsigned char si)
{
XBYTE[0xc000]=0x04;
XBYTE[0xe000]=smgduan[san];
Delay1ms();
XBYTE[0xc000]=0x08;
XBYTE[0xe000]=smgduan[si];
Delay1ms();
}
void Display3(unsigned char wu,unsigned char liu)
{
XBYTE[0xc000]=0x10;
XBYTE[0xe000]=smgduan[wu];
Delay1ms();
XBYTE[0xc000]=0x20;
XBYTE[0xe000]=smgduan[liu];
Delay1ms();
}
void Display4(unsigned char qi,unsigned char ba)
{
XBYTE[0xc000]=0x40;
XBYTE[0xe000]=smgduan[qi];
Delay1ms();
XBYTE[0xc000]=0x80;
XBYTE[0xe000]=smgduan[ba];
Delay1ms();
XBYTE[0xc000]=0x80;
XBYTE[0xe000]=0xff;
Delay1ms();
}
void InitTimer0()
{
TMOD&=0xf0;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
TR0=1;
EA=1;
ET0=1;
}
unsigned int count=0;
void ServiceTimer0() interrupt 1
{
count++;
if((yemian==1) && (count==jiange*20))
{
count=0;
Temp[T]=wendu;
T++;
if(T==10)
{
LED_kai=1;T=0;yemian=2;
yi=10;er=0;san=0;si=11;wu=11;liu=11;qi=Temp[0]/10;ba=Temp[0]%10;
}
}
if((count==20) && (yemian==2))
{
count=0;
if(LED_kai==1)
{
if(flag==0){flag=1;XBYTE[0x8000]=0xfe;}
else if(flag==1){flag=0;XBYTE[0x8000]=0xff;}
}
else if(LED_kai==0)
{
yi=10;er=0;san=T%10;si=11;wu=11;liu=10;qi=Temp[T]/10;ba=Temp[T]%10;
T++;
if(T==10)
{yemian=3;T=0;}
}
}
}
void KeyScan()
{
if(S4==0)
{
Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);
if(S4==0)
{
if(jiange==1)jiange=5;
else if(jiange==5)jiange=30;
else if(jiange==30)jiange=60;
else if(jiange==60)jiange=1;
}while(S4==0){Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);}
}
if(S5==0)
{
Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);
if(S5==0)
{
if(yemian==0){yemian=1;count=0;}
}while(S5==0){Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);}
}
if(S6==0)
{
Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);
if(S6==0)
{
LED_kai=0;XBYTE[0x8000]=0xff;
}while(S6==0){Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);}
}
if(S7==0)
{
Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);
if(S7==0)
{
if(yemian==3){yemian=0;}
}while(S7==0){Display1(yi,er);Display2(san,si);Display3(wu,liu);Display4(qi,ba);}
}
}
void main()
{
char i=0,j=0;
InitSystem();
Timer_Config();
InitTimer0();
while(1)
{
wendu=Read_Temp();
if(yemian==0){yi=11;er=11;san=11;si=11;wu=11;liu=10;qi=jiange/10;ba=jiange%10;}
else if(yemian==1)
{
Timer_Get();
if((Timer[0]%2)==0){yi=Timer[2]/10;er=Timer[2]%10;san=10;si=Timer[1]/10;wu=Timer[1]%10;liu=10;qi=Timer[0]/10;ba=Timer[0]%10;}
else {yi=Timer[2]/10;er=Timer[2]%10;san=11;si=Timer[1]/10;wu=Timer[1]%10;liu=11;qi=Timer[0]/10;ba=Timer[0]%10;}
}
KeyScan();
Display1(yi,er);
Display2(san,si);
Display3(wu,liu);
Display4(qi,ba);
}
}