Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Barometer.h@16:3e2468d4f4c1, 2015-03-20 (annotated)
- Committer:
- pvaibhav
- Date:
- Fri Mar 20 10:30:01 2015 +0000
- Revision:
- 16:3e2468d4f4c1
- Parent:
- 12:1632d7391453
- Child:
- 25:abb0f208e6a9
Barometer driver converted to new Sensor infrastructure
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pvaibhav | 1:c279bc3af90c | 1 | #ifndef _H_BAROMETER_H |
pvaibhav | 1:c279bc3af90c | 2 | #define _H_BAROMETER_H |
pvaibhav | 1:c279bc3af90c | 3 | |
pvaibhav | 1:c279bc3af90c | 4 | #include "I2CPeripheral.h" |
pvaibhav | 16:3e2468d4f4c1 | 5 | #include "Sensor.h" |
pvaibhav | 16:3e2468d4f4c1 | 6 | |
pvaibhav | 16:3e2468d4f4c1 | 7 | class Barometer : public I2CPeripheral, public Sensor |
pvaibhav | 12:1632d7391453 | 8 | { |
pvaibhav | 2:3898208e02da | 9 | private: |
pvaibhav | 16:3e2468d4f4c1 | 10 | // These typedefs are for Bosch's conversion algorithms below |
pvaibhav | 16:3e2468d4f4c1 | 11 | typedef uint32_t BMP280_U32_t; |
pvaibhav | 16:3e2468d4f4c1 | 12 | typedef int32_t BMP280_S32_t; |
pvaibhav | 16:3e2468d4f4c1 | 13 | typedef int64_t BMP280_S64_t; |
pvaibhav | 16:3e2468d4f4c1 | 14 | |
pvaibhav | 16:3e2468d4f4c1 | 15 | void bmp280_read_calibration(); |
pvaibhav | 16:3e2468d4f4c1 | 16 | float bmp280_val_to_temp(BMP280_S32_t adc_T); |
pvaibhav | 16:3e2468d4f4c1 | 17 | float bmp280_val_to_pa(BMP280_S32_t adc_P); |
pvaibhav | 16:3e2468d4f4c1 | 18 | float pressureToAltitude(const float pa) const; |
pvaibhav | 16:3e2468d4f4c1 | 19 | float startingAltitude; |
pvaibhav | 16:3e2468d4f4c1 | 20 | float lastPressure; |
pvaibhav | 16:3e2468d4f4c1 | 21 | |
pvaibhav | 16:3e2468d4f4c1 | 22 | // Calibration parameters stored on chip |
pvaibhav | 16:3e2468d4f4c1 | 23 | // XXX: DO NOT modify the order, values are read into this section of the memory sequentially! |
pvaibhav | 16:3e2468d4f4c1 | 24 | uint16_t dig_T1; |
pvaibhav | 16:3e2468d4f4c1 | 25 | int16_t dig_T2; |
pvaibhav | 16:3e2468d4f4c1 | 26 | int16_t dig_T3; |
pvaibhav | 16:3e2468d4f4c1 | 27 | uint16_t dig_P1; |
pvaibhav | 16:3e2468d4f4c1 | 28 | int16_t dig_P2; |
pvaibhav | 16:3e2468d4f4c1 | 29 | int16_t dig_P3; |
pvaibhav | 16:3e2468d4f4c1 | 30 | int16_t dig_P4; |
pvaibhav | 16:3e2468d4f4c1 | 31 | int16_t dig_P5; |
pvaibhav | 16:3e2468d4f4c1 | 32 | int16_t dig_P6; |
pvaibhav | 16:3e2468d4f4c1 | 33 | int16_t dig_P7; |
pvaibhav | 16:3e2468d4f4c1 | 34 | int16_t dig_P8; |
pvaibhav | 16:3e2468d4f4c1 | 35 | int16_t dig_P9; |
pvaibhav | 16:3e2468d4f4c1 | 36 | BMP280_S32_t t_fine; // t_fine carries fine temperature as global value |
pvaibhav | 12:1632d7391453 | 37 | |
pvaibhav | 1:c279bc3af90c | 38 | public: |
pvaibhav | 1:c279bc3af90c | 39 | Barometer(I2C &i2c); |
pvaibhav | 16:3e2468d4f4c1 | 40 | |
pvaibhav | 16:3e2468d4f4c1 | 41 | virtual bool powerOn(); |
pvaibhav | 16:3e2468d4f4c1 | 42 | virtual void powerOff(); |
pvaibhav | 16:3e2468d4f4c1 | 43 | virtual void start(); |
pvaibhav | 16:3e2468d4f4c1 | 44 | virtual void stop(); |
pvaibhav | 16:3e2468d4f4c1 | 45 | |
pvaibhav | 16:3e2468d4f4c1 | 46 | virtual Vector3 read(); |
pvaibhav | 1:c279bc3af90c | 47 | }; |
pvaibhav | 1:c279bc3af90c | 48 | |
pvaibhav | 1:c279bc3af90c | 49 | #endif |