Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Barometer.h@46:fd5a62296b12, 2015-05-27 (annotated)
- Committer:
- pvaibhav
- Date:
- Wed May 27 13:01:43 2015 +0000
- Revision:
- 46:fd5a62296b12
- Parent:
- 25:abb0f208e6a9
Code reformatted
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 | 46:fd5a62296b12 | 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 | 25:abb0f208e6a9 | 19 | float sum; |
pvaibhav | 25:abb0f208e6a9 | 20 | float avg; |
pvaibhav | 25:abb0f208e6a9 | 21 | int nsamples; |
pvaibhav | 46:fd5a62296b12 | 22 | |
pvaibhav | 16:3e2468d4f4c1 | 23 | // Calibration parameters stored on chip |
pvaibhav | 16:3e2468d4f4c1 | 24 | // XXX: DO NOT modify the order, values are read into this section of the memory sequentially! |
pvaibhav | 16:3e2468d4f4c1 | 25 | uint16_t dig_T1; |
pvaibhav | 16:3e2468d4f4c1 | 26 | int16_t dig_T2; |
pvaibhav | 16:3e2468d4f4c1 | 27 | int16_t dig_T3; |
pvaibhav | 16:3e2468d4f4c1 | 28 | uint16_t dig_P1; |
pvaibhav | 16:3e2468d4f4c1 | 29 | int16_t dig_P2; |
pvaibhav | 16:3e2468d4f4c1 | 30 | int16_t dig_P3; |
pvaibhav | 16:3e2468d4f4c1 | 31 | int16_t dig_P4; |
pvaibhav | 16:3e2468d4f4c1 | 32 | int16_t dig_P5; |
pvaibhav | 16:3e2468d4f4c1 | 33 | int16_t dig_P6; |
pvaibhav | 16:3e2468d4f4c1 | 34 | int16_t dig_P7; |
pvaibhav | 16:3e2468d4f4c1 | 35 | int16_t dig_P8; |
pvaibhav | 16:3e2468d4f4c1 | 36 | int16_t dig_P9; |
pvaibhav | 16:3e2468d4f4c1 | 37 | BMP280_S32_t t_fine; // t_fine carries fine temperature as global value |
pvaibhav | 12:1632d7391453 | 38 | |
pvaibhav | 1:c279bc3af90c | 39 | public: |
pvaibhav | 1:c279bc3af90c | 40 | Barometer(I2C &i2c); |
pvaibhav | 16:3e2468d4f4c1 | 41 | |
pvaibhav | 16:3e2468d4f4c1 | 42 | virtual bool powerOn(); |
pvaibhav | 16:3e2468d4f4c1 | 43 | virtual void powerOff(); |
pvaibhav | 16:3e2468d4f4c1 | 44 | virtual void start(); |
pvaibhav | 16:3e2468d4f4c1 | 45 | virtual void stop(); |
pvaibhav | 16:3e2468d4f4c1 | 46 | |
pvaibhav | 16:3e2468d4f4c1 | 47 | virtual Vector3 read(); |
pvaibhav | 1:c279bc3af90c | 48 | }; |
pvaibhav | 1:c279bc3af90c | 49 | |
pvaibhav | 1:c279bc3af90c | 50 | #endif |