|
void menu_dis() //计算速度函数
{
static uchar value;
if(menu_1 == 0)
{
if(flag_1s == 1)
{
flag_1s = 0;
if(flag_en == 0)
{
value ++;
if(value >= 3) //2秒
{
speed_km = 0; //速度为0
shudu = (uint)speed_km;
value = 0;
}
}
if((flag_en == 1))
{
value = 0;
flag_en = 0;
//1s = 1 / 1000000us; // 1m/s=3.6km/h
f_hz = (t2_num * 65536.0 + TH11 * 256 + TL11) / 1000000 ; //算出来就是秒
t2_num = 0; //把变量清零
TH11 = 0;
TL11 = 0;
speed_m = f_hz * zhijing * 3.14 ; //算出来的是m/s
juli_z = (juli_z + (uint)speed_m) ; //总路程m
speed_km = speed_m * 3.6 ; //(带个小数点) km/h
shudu = (uint)speed_km;
zong_lc += speed_m;
}
write_sfm2(1,3,shudu);
write_sfm4(2,3,juli_z);
}
}
}
f_hz = (t2_num * 65536.0 + TH11 * 256 + TL11) / 1000000 ; //算出来就是秒
speed_m = f_hz * zhijing * 3.14 ; //算出来的是m/s
这两句不理解
|
|