diff options
Diffstat (limited to 'peripheral/libupm/src/bmpx8x/bmpx8x.cxx')
-rw-r--r-- | peripheral/libupm/src/bmpx8x/bmpx8x.cxx | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/peripheral/libupm/src/bmpx8x/bmpx8x.cxx b/peripheral/libupm/src/bmpx8x/bmpx8x.cxx index 058e265..5bf7f57 100644 --- a/peripheral/libupm/src/bmpx8x/bmpx8x.cxx +++ b/peripheral/libupm/src/bmpx8x/bmpx8x.cxx @@ -28,14 +28,14 @@ #include <unistd.h> #include <stdlib.h> -#include "bmpx8x.h" +#include "bmpx8x.hpp" using namespace upm; BMPX8X::BMPX8X (int bus, int devAddr, uint8_t mode) : m_controlAddr(devAddr), m_i2ControlCtx(bus) { - + m_name = "BMPX8X"; - + mraa::Result ret = m_i2ControlCtx.address(m_controlAddr); if (ret != mraa::SUCCESS) { throw std::invalid_argument(std::string(__FUNCTION__) + @@ -93,7 +93,8 @@ BMPX8X::getPressure () { B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling ); if (B7 < 0x80000000) { - p = (B7 * 2) / B4; + p = (B7 * 2) / B4 +; } else { p = (B7 / B4) * 2; } @@ -169,6 +170,18 @@ BMPX8X::getAltitude (float sealevelPressure) { return altitude; } + +int +BMPX8X::getTemperatureCelcius() { + return static_cast<int>(getTemperature() + 0.5); +} + +const char* +BMPX8X::getModuleName() { + return m_name.c_str(); +} + + int32_t BMPX8X::computeB5(int32_t UT) { int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15; |