From eb69ce74d0fe5fa6c1847c3fbbc19ac6c87b8270 Mon Sep 17 00:00:00 2001 From: 95384 <664090429@qq.com> Date: Mon, 25 Nov 2024 22:45:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E4=B8=80=E4=B8=AA=E6=96=B9=E5=90=91?= =?UTF-8?q?=E7=9A=84=E6=8D=A2=E8=83=BD=E5=99=A8=E9=80=9A=E9=81=93=E5=9D=8F?= =?UTF-8?q?=E6=8E=89=E6=97=B6=EF=BC=8C=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E7=94=B1=E8=AF=A5=E9=80=9A=E9=81=93=E9=A3=8E=E9=80=9F=E9=A3=8E?= =?UTF-8?q?=E5=90=91=E5=BD=92=E9=9B=B6=E6=94=B9=E4=B8=BA=E6=95=B4=E4=BD=93?= =?UTF-8?q?=E9=A3=8E=E9=80=9F=E9=A3=8E=E5=90=91=E5=BD=92=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Src/anemometer_dev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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//