add Rf link quality checks
[openXsensor.git] / openXsensor / oXs_bmp280.h
blob47dea5177b261b31e64be9c9c89a9188c730c072
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"
12 #define BMP280_ADR 0x77 // I2C address of BMP280 (can also be 0x76
14 /*=========================================================================
15 CALIBRATION DATA for BMP280
16 -----------------------------------------------------------------------*/
17 typedef struct
19 uint16_t dig_T1;
20 int16_t dig_T2;
21 int16_t dig_T3;
22 uint16_t dig_P1;
23 int16_t dig_P2;
24 int16_t dig_P3;
25 int16_t dig_P4;
26 int16_t dig_P5;
27 int16_t dig_P6;
28 int16_t dig_P7;
29 int16_t dig_P8;
30 int16_t dig_P9;
31 } BMP280_CALIB_DATA;
32 /*=========================================================================*/
34 class OXS_BMP280 {
35 public:
36 #ifdef DEBUG
37 OXS_BMP280( HardwareSerial &print);
38 #else
39 OXS_BMP280( void ) ;
40 #endif
41 VARIODATA varioData ;
42 void setup();
43 bool readSensor();
44 void resetValues();
46 private:
47 uint8_t _addr;
49 uint8_t errorI2C ; //error code returned by I2C::Write and I2C::Read; 0 = no error
50 bool errorCalibration ; // (true = error)
51 void SendCommand(byte command);
52 long getData(byte command, byte del);
53 void calculateVario() ;
54 uint16_t low, high;
56 int32_t D1 ;
57 int32_t D2 ;
58 int32_t D2Prev ;
59 int32_t D2Apply ;
60 int64_t dT ;
61 int32_t TEMP ;
62 int64_t OFF, SENS;
63 int16_t alt_temp_compensation ;
65 int32_t altitude ; // in cm * 100
66 int32_t altitudeLowPass ;
67 int32_t altitudeHighPass ;
68 int sensitivityMin ;
71 unsigned long extended2Micros ; // used to temporarilly save micros() >> 1
72 unsigned long pressureMicros ; // save time when program send command asking the MS5611 to get the pressure
73 unsigned long pressureMicrosPrev1 ; // save the previous pressureMicros
74 unsigned long pressureMicrosPrev2 ; // save the previous of the previous pressureMicros
75 unsigned long altMillis ;
76 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)
77 unsigned long nextAverageAltMillis ; // save when AverageAltitude has to be calculated
79 float climbRate2AltFloat ;
81 float abs_deltaClimbRate ;
83 #ifdef DEBUG
84 HardwareSerial* printer;
85 #endif
86 }; // end class OXS_BMP280
89 #endif // OXS_BMP280