UBlox M10 Support
[openXsensor.git] / openXsensor / oXs_bmp280.h
blobc45464bfb6e93de2c4c760204dba676b3b76dac6
1 #ifndef OXS_BMP280_h
2 #define OXS_BMP280_h
5 #include "Arduino.h"
6 #include "oXs_config_basic.h"
7 #include "oXs_config_advanced.h"
8 #include "oXs_config_macros.h"
9 #include "I2C.h"
10 #include "oXs_ms5611.h"
11 #ifndef BMP280_ADR
12 #define BMP280_ADR 0x76 // I2C address of BMP280 (can also be 0x76
13 #endif
15 /*=========================================================================
16 CALIBRATION DATA for BMP280
17 -----------------------------------------------------------------------*/
18 typedef struct
20 uint16_t dig_T1;
21 int16_t dig_T2;
22 int16_t dig_T3;
23 uint16_t dig_P1;
24 int16_t dig_P2;
25 int16_t dig_P3;
26 int16_t dig_P4;
27 int16_t dig_P5;
28 int16_t dig_P6;
29 int16_t dig_P7;
30 int16_t dig_P8;
31 int16_t dig_P9;
32 } BMP280_CALIB_DATA;
33 /*=========================================================================*/
35 class OXS_BMP280 {
36 public:
37 #ifdef DEBUG
38 OXS_BMP280( HardwareSerial &print);
39 #else
40 OXS_BMP280( void ) ;
41 #endif
42 VARIODATA varioData ;
43 void setup();
44 bool readSensor();
45 void resetValues();
47 private:
48 uint8_t _addr;
50 uint8_t errorI2C ; //error code returned by I2C::Write and I2C::Read; 0 = no error
51 bool errorCalibration ; // (true = error)
52 void SendCommand(byte command);
53 long getData(byte command, byte del);
54 void calculateVario() ;
55 uint16_t low, high;
57 int32_t D1 ;
58 int32_t D2 ;
59 int32_t D2Prev ;
60 int32_t D2Apply ;
61 int64_t dT ;
62 int32_t TEMP ;
63 int64_t OFF, SENS;
64 int16_t alt_temp_compensation ;
66 int32_t altitude ; // in cm * 100
67 int32_t altitudeLowPass ;
68 int32_t altitudeHighPass ;
69 int sensitivityMin ;
72 unsigned long extended2Micros ; // used to temporarilly save micros() >> 1
73 unsigned long pressureMicros ; // save time when program send command asking the MS5611 to get the pressure
74 unsigned long pressureMicrosPrev1 ; // save the previous pressureMicros
75 unsigned long pressureMicrosPrev2 ; // save the previous of the previous pressureMicros
76 unsigned long altMillis ;
77 unsigned long nextAltMillis ; // save when Altitude has to be calculated; altitude is available only after 3200 in order to get a stable value (less temperature drift)
78 unsigned long nextAverageAltMillis ; // save when AverageAltitude has to be calculated
80 float climbRate2AltFloat ;
82 float abs_deltaClimbRate ;
84 #ifdef DEBUG
85 HardwareSerial* printer;
86 #endif
87 }; // end class OXS_BMP280
89 #endif // OXS_BMP280