mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-08 02:17:07 +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.
|
||||
|
||||
// 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:
|
||||
|
||||
Reference in New Issue
Block a user