mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-ms56xx.git
synced 2025-06-10 18:16:00 +00:00
Added simple barometric formula to MS5611 driver
This commit is contained in:
parent
fa30a28b45
commit
afe9b83b01
@ -169,6 +169,10 @@ namespace sta
|
|||||||
* @return float The altitude estimate in meters.
|
* @return float The altitude estimate in meters.
|
||||||
*/
|
*/
|
||||||
float getAltitudeEstimate();
|
float getAltitudeEstimate();
|
||||||
|
|
||||||
|
static float getSeaLevel(float pressRef, float altRef);
|
||||||
|
|
||||||
|
static float getAltitudeEstimate(float pressure, float sealevel);
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Reset the sensor.
|
* @brief Reset the sensor.
|
||||||
|
@ -121,6 +121,16 @@ namespace sta
|
|||||||
return altitude;
|
return altitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MS56xx::getSeaLevel(float pressRef, float altRef)
|
||||||
|
{
|
||||||
|
return pressRef / (std::pow((1 - altRef / 44330), 5.255));
|
||||||
|
}
|
||||||
|
|
||||||
|
float MS56xx::getAltitudeEstimate(float pressure, float sealevel)
|
||||||
|
{
|
||||||
|
return 44330 * (1 - std::pow(pressure / sealevel, 1 / 5.255));
|
||||||
|
}
|
||||||
|
|
||||||
void MS56xx::readPROM() {
|
void MS56xx::readPROM() {
|
||||||
uint8_t buffer[2];
|
uint8_t buffer[2];
|
||||||
|
|
||||||
@ -218,4 +228,4 @@ namespace sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // STA_SPATZ_ENABLED
|
#endif // STA_SPATZ_ENABLED
|
||||||
|
24
src/mock.cpp
24
src/mock.cpp
@ -93,15 +93,25 @@ namespace sta
|
|||||||
sealevel_ = pressRef / (std::pow((1 - altRef / 44330), 5.255));
|
sealevel_ = pressRef / (std::pow((1 - altRef / 44330), 5.255));
|
||||||
}
|
}
|
||||||
|
|
||||||
float MS56xx::getAltitudeEstimate()
|
float MS56xx::getAltitudeEstimate()
|
||||||
{
|
{
|
||||||
float pressure = getPressure(Unit::hPa);
|
float pressure = getPressure(Unit::hPa);
|
||||||
|
|
||||||
// Taken from: https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf, page 16
|
// Taken from: https://cdn-shop.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf, page 16
|
||||||
float altitude = 44330 * (1 - std::pow(pressure / sealevel_, 1 / 5.255));
|
float altitude = 44330 * (1 - std::pow(pressure / sealevel_, 1 / 5.255));
|
||||||
|
|
||||||
return altitude;
|
return altitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MS56xx::getSeaLevel(float pressRef, float altRef)
|
||||||
|
{
|
||||||
|
return pressRef / (std::pow((1 - altRef / 44330), 5.255));
|
||||||
|
}
|
||||||
|
|
||||||
|
float MS56xx::getAltitudeEstimate(float pressure, float sealevel)
|
||||||
|
{
|
||||||
|
return 44330 * (1 - std::pow(pressure / sealevel, 1 / 5.255));
|
||||||
|
}
|
||||||
|
|
||||||
void MS56xx::readPROM() {
|
void MS56xx::readPROM() {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user