将一个方向的换能器通道坏掉时,处理逻辑由该通道风速风向归零改为整体风速风向归零

This commit is contained in:
95384 2024-11-25 22:45:25 +08:00
parent 30a4ed6d76
commit eb69ce74d0
1 changed files with 10 additions and 2 deletions

View File

@ -531,8 +531,17 @@ void wind_task(void const * argument)
/* 一阶低通滤波器 */ /* 一阶低通滤波器 */
av_speed = sqrtf(av_speedx*av_speedx + av_speedy*av_speedy); av_speed = sqrtf(av_speedx*av_speedx + av_speedy*av_speedy);
av_angle = acosf(av_speedx/(av_speed+0.00000001))/2/PI*360; 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) if(av_speedy<0)
av_angle = 360-av_angle; av_angle = 360-av_angle;
// 速度太小视为0风速
if(fabs(av_speed)<0.1) if(fabs(av_speed)<0.1)
{ {
av_speed = 0; 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("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); ///term_printf("win_speed %.2f \r\n",weather_info.wind_velocity);
//HAL_Delay(1); //HAL_Delay(1);
//osDelay(3// //osDelay(3//