Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Diff: Barometer.cpp
- Revision:
- 4:e759b8c756da
- Parent:
- 3:ee90a9ada112
- Child:
- 16:3e2468d4f4c1
--- a/Barometer.cpp Wed Jan 21 10:34:45 2015 +0000 +++ b/Barometer.cpp Fri Jan 23 13:00:46 2015 +0000 @@ -2,6 +2,20 @@ #define DEBUG "BMP280" #include "Logger.h" +Barometer::Barometer(I2C &i2c) : I2CPeripheral(i2c, 0xEC /* address */) +{ + write_reg(0xE0, 0xB6); // reset + wait_ms(2); // cf. datasheet page 8, t_startup + const uint8_t chip_id = read_reg(0xD0); + if (chip_id == 0x58) { + bmp280_read_calibration(); + //setFilterCoefficient(kFilter_16x); + INFO("Bosch Sensortec BMP280 ready"); + } else { + WARN("Bosch Sensortec BMP280 not found (chip ID=0x%02x, expected=0x58)", chip_id); + } +} + // Calibration parameters stored on chip static uint16_t dig_T1; static int16_t dig_T2; @@ -130,20 +144,6 @@ return ((BMP280_U32_t)p) / 256.0; } -Barometer::Barometer(I2C &i2c) : I2CPeripheral(i2c, 0xEC /* address */) -{ - write_reg(0xE0, 0xB6); // reset - wait_ms(2); // cf. datasheet page 8, t_startup - const uint8_t chip_id = read_reg(0xD0); - if (chip_id == 0x58) { - bmp280_read_calibration(); - //setFilterCoefficient(kFilter_16x); - INFO("Bosch Sensortec BMP280 ready"); - } else { - WARN("Bosch Sensortec BMP280 not found (chip ID=0x%02x, expected=0x58)", chip_id); - } -} - double Barometer::getPressure() { takeMeasurement(kSkip, kOversample_16x);