#include"UT.h"
void Count()
{unsigned int time,flag;
unsigned long S;
unsigned char code ASCII[15] ={'0','1','2','3','4','5','6','7','8','9','.','-','M'};
unsigned char disbuff[4]={0,0,0,0};
time=TH0*256+TL0;
TH0=0x00;
TL0=0x00;
S=(time*1.7)/100; //算出来是CM
if((S>=700)||flag==1) //超出测量范围显示“-”
{
flag=0;
DisplayOneChar(0, 0, ASCII[11]);
DisplayOneChar(1, 0, ASCII[10]); //显示点
DisplayOneChar(2, 0, ASCII[11]);
DisplayOneChar(3, 0, ASCII[11]);
DisplayOneChar(4, 0, ASCII[12]); //显示M
}
else
{
disbuff[0]=S%1000/100;
disbuff[1]=S%1000%100/10;
disbuff[2]=S%1000%10 %10;
DisplayOneChar(0, 0, ASCII[disbuff[0]]);
DisplayOneChar(1, 0, ASCII[10]); //显示点
DisplayOneChar(2, 0, ASCII[disbuff[1]]);
DisplayOneChar(3, 0, ASCII[disbuff[2]]);
DisplayOneChar(4, 0, ASCII[12]); //显示M
}
}
void StartModule() //启动模块
{
Trig=1; //启动一次模块
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
Trig=0;
}
|