Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Diff: Barometer.h
- Revision:
- 16:3e2468d4f4c1
- Parent:
- 12:1632d7391453
- Child:
- 25:abb0f208e6a9
--- a/Barometer.h Wed Mar 18 15:34:51 2015 +0000 +++ b/Barometer.h Fri Mar 20 10:30:01 2015 +0000 @@ -2,19 +2,48 @@ #define _H_BAROMETER_H #include "I2CPeripheral.h" -class Barometer : public I2CPeripheral +#include "Sensor.h" + +class Barometer : public I2CPeripheral, public Sensor { private: - void setFilterCoefficient(const uint8_t iir); - void takeMeasurement(const uint8_t tmpovr, const uint8_t psrovr); - void bmp280_read_cal_reg(const uint8_t reg, char* val); - void bmp280_read_calibration(); + // These typedefs are for Bosch's conversion algorithms below + typedef uint32_t BMP280_U32_t; + typedef int32_t BMP280_S32_t; + typedef int64_t BMP280_S64_t; + + void bmp280_read_calibration(); + float bmp280_val_to_temp(BMP280_S32_t adc_T); + float bmp280_val_to_pa(BMP280_S32_t adc_P); + float pressureToAltitude(const float pa) const; + float startingAltitude; + float lastPressure; + + // Calibration parameters stored on chip + // XXX: DO NOT modify the order, values are read into this section of the memory sequentially! + uint16_t dig_T1; + int16_t dig_T2; + int16_t dig_T3; + uint16_t dig_P1; + int16_t dig_P2; + int16_t dig_P3; + int16_t dig_P4; + int16_t dig_P5; + int16_t dig_P6; + int16_t dig_P7; + int16_t dig_P8; + int16_t dig_P9; + BMP280_S32_t t_fine; // t_fine carries fine temperature as global value public: Barometer(I2C &i2c); - double getPressure(); - double getAltitude(); - double getTemperature(); + + virtual bool powerOn(); + virtual void powerOff(); + virtual void start(); + virtual void stop(); + + virtual Vector3 read(); }; #endif \ No newline at end of file