From b713b75cf0a3accfbb5da036c56f49d7a46c598b Mon Sep 17 00:00:00 2001 From: 95384 <664090429@qq.com> Date: Tue, 3 Dec 2024 16:53:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=85=AC=E5=BC=8F=E4=B8=AD=E7=9A=842c?= =?UTF-8?q?os45=E6=94=B9=E4=B8=BA=E5=AE=8F=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Inc/anemometer_dev.h | 3 +++ App/Src/anemometer_dev.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/App/Inc/anemometer_dev.h b/App/Inc/anemometer_dev.h index c22e84d..c09a808 100644 --- a/App/Inc/anemometer_dev.h +++ b/App/Inc/anemometer_dev.h @@ -53,6 +53,9 @@ // 富奥通结构 L = 118946 // #define DISTANCE 118946 +// 公式中的二倍cos45 +#define TWO_COS45 1.41421356237309f + // x方向 #define WIND_DIRECTION_X 0x00 // y方向 diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index 08a8aa9..208fcab 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -442,7 +442,7 @@ void wind_task(void const * argument) weather_info.wind_c = (g_stConfigInfo.transducer_distace * 2.0f)/2.0f*(1.0f/tofx+1.0f/tofy); // weather_info.wind_velocity_x = 0-DISTANCE*dtof/1.41422f/tofx/tofx; // 修正公式 - weather_info.wind_velocity_x = 0-(g_stConfigInfo.transducer_distace * 2.0f)*dtof/1.41422f/tofx/tofy; + weather_info.wind_velocity_x = 0-(g_stConfigInfo.transducer_distace * 2.0f)*dtof/TWO_COS45/tofx/tofy; } // 通道3 通道4 测试东西风速 @@ -502,7 +502,7 @@ void wind_task(void const * argument) weather_info.wind_c = (g_stConfigInfo.transducer_distace * 2.0f)/2.0f*(1.0f/tofx+1.0f/tofy); // weather_info.wind_velocity_y = DISTANCE*dtof/1.41422f/tofx/tofx; // 修正公式 - weather_info.wind_velocity_y = (g_stConfigInfo.transducer_distace * 2.0f)*dtof/1.41422f/tofx/tofy; + weather_info.wind_velocity_y = (g_stConfigInfo.transducer_distace * 2.0f)*dtof/TWO_COS45/tofx/tofy; } weather_info.wind_velocity = sqrtf(weather_info.wind_velocity_x*weather_info.wind_velocity_x + weather_info.wind_velocity_y*weather_info.wind_velocity_y);