diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index 6a49a37..90a3a95 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -519,7 +519,7 @@ void wind_task(void const * argument) speedy[speedi] = weather_info.wind_velocity_y; speed[speedi] = weather_info.wind_velocity; angle[speedi++] = weather_info.wind_angle*180/PI; - + if(speedi>=AV_SPEED_LEN) { speedi=0; @@ -531,8 +531,17 @@ void wind_task(void const * argument) /* 一阶低通滤波器 */ av_speed = sqrtf(av_speedx*av_speedx + av_speedy*av_speedy); av_angle = acosf(av_speedx/(av_speed+0.00000001))/2/PI*360; + + // 有错时风速风向归零 + if(g_error_log.tof_error_NS || g_error_log.tof_error_WE) + { + av_speed = 0; + av_angle = 0; + } + // 360一圈 if(av_speedy<0) av_angle = 360-av_angle; + // 速度太小视为0风速 if(fabs(av_speed)<0.1) { av_speed = 0; @@ -540,7 +549,6 @@ void wind_task(void const * argument) } /// term_printf("x:%.2f y:%.2f win_speed %.2f m/s angle %.2f \r\n",av_speedx,av_speedy,av_speed,av_angle); } - ///term_printf("win_speed %.2f \r\n",weather_info.wind_velocity); //HAL_Delay(1); //osDelay(3//