程序有点多,我就捡跟问题相关的贴哈
===============main.c============================
ulong Pulse_N1=0;
.....................
int main( void )
{
Clock_Init();
IoDir();
Port_Init();
DS1302_init(); //DS1302初始化
delay_ms(10);
DS1302_write_time(); //向DS1302写初始数据,如年月和时间等
_EINT(); //系统中断允许
Display_Host();
delay_ms(1000);
GUI_FillSCR(YELLOW);
fun0(); //进入主菜单
}
#pragma vector=PORT2_VECTOR //P2(P2.1)中断服务子程序
__interrupt void P2_Interrupt(void)
{
if(P2IFG==0X08 )
{
Pulse_N2++;
}
P2IFG=0;
}
============================fun.c====================
extern ulong Pulse_N1;
void fun0()//主菜单
{
Port_Init();
GUI_RectangleFill(0,0,138,5,GRAY);
GUI_RectangleFill(0,0,5,272,GRAY);
GUI_RectangleFill(133,0,138,272,GRAY);
GUI_RectangleFill(0,267,138,272,GRAY);
GUI_RectangleFill(0,70,138,72,GRAY);
GUI_RectangleFill(0,135,138,137,GRAY);
GUI_RectangleFill(0,200,138,202,GRAY);
GUI_RectangleFill(139,0,479,272,YELLOW);
DStr_H32_N96(5,22,"模式设置",BLUE,RED);
DStr_H32_N96(5,87,"时间设置",BLUE,GRAY1);
DStr_H32_N96(5,152,"查询功能",BLUE,GRAY1);
DStr_H32_N96(5,217,"报警设置",BLUE,GRAY1);
}
..........................省略了...........................
void fun24()
{
GUI_FillSCR(YELLOW);
GUI_HLine(5,30,475,RED);
DrawString(5,40,"间隔时间",BLUE,YELLOW,TRANSP);
if(Interval_time==5)
{DrawString(80,65,"5 minutes",BLUE,YELLOW,TRANSP);}
if(Interval_time==10)
{DrawString(80,65,"10 minutes",BLUE,YELLOW,TRANSP);}
if(Interval_time==20)
{DrawString(80,65,"20 minutes",BLUE,YELLOW,TRANSP);}
if(Interval_time==30)
{DrawString(80,65,"30 minutes",BLUE,YELLOW,TRANSP);}
if(Interval_time==60)
{DrawString(80,65,"1 hour",BLUE,YELLOW,TRANSP);}
if(Interval_time==120)
{DrawString(80,65,"2 hours",BLUE,YELLOW,TRANSP);};
GUI_HLine(5,90,475,RED);
DrawString(5,100,"间隔期内排量:",BLUE,YELLOW,TRANSP);
DStr_H32_N96(20,140,"127",BLUE,YELLOW);
GUI_RLine(200, 115, 265, RED);
DrawString(210,100,"总尿量:",BLUE,YELLOW,TRANSP);
DrawString(178,245,"mL",BLUE,YELLOW,TRANSP);
DrawString(445,245,"mL",BLUE,YELLOW,TRANSP);
uchar temp1;
while((P1IFG&BIT4)==0)
{
Urine_V1=(uint)(0.107*Pulse_N1+9);
Urine_V2=(uint)(0.306*Pulse_N2+10);
Urine_V=Urine_V1+Urine_V2;
Urine_N[0]=(Urine_V/1000)%10; //千位
Urine_N[1]=(Urine_V/100)%10; //百位
Urine_N[2]=(Urine_V/10)%10; //十位
Urine_N[3]=Urine_V%10; //个位
for(uint i=0;i