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);