mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 12:21:36 +08:00
BMP280 wrapper: Clean up floating point operations
This commit is contained in:
@@ -169,7 +169,7 @@ int DfBmp280Wrapper::_publish(struct baro_sensor_data &data)
|
|||||||
// TODO: verify this, it's just copied from the MS5611 driver.
|
// TODO: verify this, it's just copied from the MS5611 driver.
|
||||||
|
|
||||||
// Constant for now
|
// 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 */
|
/* tropospheric properties (0-11km) for standard atmosphere */
|
||||||
const double T1 = 15.0 + 273.15; /* temperature at base height in Kelvin */
|
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 */
|
const double R = 287.05; /* ideal gas constant in J/kg/K */
|
||||||
|
|
||||||
/* current pressure at MSL in kPa */
|
/* current pressure at MSL in kPa */
|
||||||
double p1 = MSL_PRESSURE / 1000.0f;
|
double p1 = MSL_PRESSURE_KPA;
|
||||||
|
|
||||||
/* measured pressure in kPa */
|
/* measured pressure in kPa */
|
||||||
double p = data.pressure_pa / 1000.0f;
|
double p = static_cast<double>(data.pressure_pa) / 1000.0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Solve:
|
* Solve:
|
||||||
|
|||||||
Reference in New Issue
Block a user