BMP280 wrapper: Clean up floating point operations

This commit is contained in:
Lorenz Meier
2016-05-19 15:44:37 +02:00
parent 9027ff4372
commit c67907ffb2
@@ -169,7 +169,7 @@ int DfBmp280Wrapper::_publish(struct baro_sensor_data &data)
// TODO: verify this, it's just copied from the MS5611 driver.
// Constant for now
const float MSL_PRESSURE = 101325.0f;
const double MSL_PRESSURE_KPA = 101325.0 / 1000.0;
/* tropospheric properties (0-11km) for standard atmosphere */
const double T1 = 15.0 + 273.15; /* temperature at base height in Kelvin */
@@ -178,10 +178,10 @@ int DfBmp280Wrapper::_publish(struct baro_sensor_data &data)
const double R = 287.05; /* ideal gas constant in J/kg/K */
/* current pressure at MSL in kPa */
double p1 = MSL_PRESSURE / 1000.0f;
double p1 = MSL_PRESSURE_KPA;
/* measured pressure in kPa */
double p = data.pressure_pa / 1000.0f;
double p = static_cast<double>(data.pressure_pa) / 1000.0;
/*
* Solve: