AC_Baro: add floating point constant designators

This commit is contained in:
Peter Barker 2019-04-05 09:06:32 +11:00 committed by Tom Pittenger
parent d59cf15594
commit 10cc05c8ed
4 changed files with 6 additions and 6 deletions

View File

@ -164,13 +164,13 @@ void AP_Baro_DPS280::calculate_PT(int32_t UT, int32_t UP, float &pressure, float
{ {
const struct dps280_cal &cal = calibration; const struct dps280_cal &cal = calibration;
// scaling for 16x oversampling // scaling for 16x oversampling
const float scaling_16 = 1.0/253952; const float scaling_16 = 1.0f/253952;
float temp_scaled; float temp_scaled;
float press_scaled; float press_scaled;
temp_scaled = float(UT) * scaling_16; temp_scaled = float(UT) * scaling_16;
temperature = cal.C0 * 0.5 + cal.C1 * temp_scaled; temperature = cal.C0 * 0.5f + cal.C1 * temp_scaled;
press_scaled = float(UP) * scaling_16; press_scaled = float(UP) * scaling_16;

View File

@ -74,7 +74,7 @@ void AP_Baro::SimpleUnderWaterAtmosphere(
// \f$T(D)\approx\frac{S}{1.8 \cdot 10^{-4} \cdot S \cdot T + 1}\f$ // \f$T(D)\approx\frac{S}{1.8 \cdot 10^{-4} \cdot S \cdot T + 1}\f$
const float seaTempSurface = 15.0f; // Celsius const float seaTempSurface = 15.0f; // Celsius
const float S = seaTempSurface * 0.338f; const float S = seaTempSurface * 0.338f;
theta = 1.0f / ((1.8e-4) * S * (alt * 1e3) + 1.0f); theta = 1.0f / ((1.8e-4f) * S * (alt * 1e3f) + 1.0f);
} }
/* /*

View File

@ -296,7 +296,7 @@ static struct {
void AP_Baro_ICM20789::convert_data(uint32_t Praw, uint32_t Traw) void AP_Baro_ICM20789::convert_data(uint32_t Praw, uint32_t Traw)
{ {
// temperature is easy // temperature is easy
float T = -45 + (175.0 / (1U<<16)) * Traw; float T = -45 + (175.0f / (1U<<16)) * Traw;
// pressure involves a few more calculations // pressure involves a few more calculations
float P = get_pressure(Praw, Traw); float P = get_pressure(Praw, Traw);

View File

@ -224,7 +224,7 @@ void AP_Baro_LPS2XH::_update_temperature(void)
WITH_SEMAPHORE(_sem); WITH_SEMAPHORE(_sem);
if (_lps2xh_type == BARO_LPS25H) { if (_lps2xh_type == BARO_LPS25H) {
_temperature=((float)(Temp_Reg_s16/480)+42.5); _temperature=((float)(Temp_Reg_s16/480)+42.5f);
} }
if (_lps2xh_type == BARO_LPS22H) { if (_lps2xh_type == BARO_LPS22H) {
_temperature=(float)(Temp_Reg_s16/100); _temperature=(float)(Temp_Reg_s16/100);
@ -237,7 +237,7 @@ void AP_Baro_LPS2XH::_update_pressure(void)
uint8_t pressure[3]; uint8_t pressure[3];
_dev->read_registers(PRESS_OUT_XL_ADDR, pressure, 3); _dev->read_registers(PRESS_OUT_XL_ADDR, pressure, 3);
int32_t Pressure_Reg_s32 = ((uint32_t)pressure[2]<<16)|((uint32_t)pressure[1]<<8)|(uint32_t)pressure[0]; int32_t Pressure_Reg_s32 = ((uint32_t)pressure[2]<<16)|((uint32_t)pressure[1]<<8)|(uint32_t)pressure[0];
int32_t Pressure_mb = Pressure_Reg_s32 * (100.0 / 4096); // scale for pa int32_t Pressure_mb = Pressure_Reg_s32 * (100.0f / 4096); // scale for pa
WITH_SEMAPHORE(_sem); WITH_SEMAPHORE(_sem);
_pressure = Pressure_mb; _pressure = Pressure_mb;