meas_airspeed: avoid trivial dependency on math lib

including the math lib adds a huge amount to flash usage
This commit is contained in:
Andrew Tridgell 2014-01-07 11:37:40 +08:00 committed by Lorenz Meier
parent d4d2571161
commit 1f564a95ee
1 changed files with 3 additions and 1 deletions

View File

@ -198,7 +198,9 @@ MEASAirspeed::collect()
// uint16_t diff_press_pa = abs(dp_raw - (16384 / 2.0f)); // uint16_t diff_press_pa = abs(dp_raw - (16384 / 2.0f));
const float P_min = -1.0f; const float P_min = -1.0f;
const float P_max = 1.0f; const float P_max = 1.0f;
float diff_press_pa = math::max(0.0f, fabsf( ( ((float)dp_raw - 0.1f*16383.0f) * (P_max-P_min)/(0.8f*16383.0f) + P_min) * 6894.8f) - _diff_pres_offset); float diff_press_pa = fabsf( ( ((float)dp_raw - 0.1f*16383.0f) * (P_max-P_min)/(0.8f*16383.0f) + P_min) * 6894.8f) - _diff_pres_offset;
if (diff_press_pa < 0.0f)
diff_press_pa = 0.0f;
struct differential_pressure_s report; struct differential_pressure_s report;