Merge branch 'master' into change-to-sending-expresslrs_RFrates_e-in-sync-packet
[ExpressLRS.git] / src / lib / Baro / baro_spl06.h
blobe30fc93ab58f9aca03d4f0bb9227aacb66ea568f
1 #pragma once
3 #include "baro_base.h"
4 #include "baro_spl06_regs.h"
6 class SPL06 : public BaroI2CBase
8 public:
9 SPL06() : BaroI2CBase(), m_calib{0} {}
11 // Detect if chip is present
12 static bool detect();
14 // BaroBase methods
15 void initialize();
16 uint8_t getPressureDuration();
17 void startPressure();
18 uint32_t getPressure();
19 uint8_t getTemperatureDuration();
20 void startTemperature();
21 int32_t getTemperature();
22 protected:
23 // 32x Pressure + 8x Temperature = 70ms per update
24 // 4x=8.4ms/2.5PaRMS, 8x=14.8ms, 16x=27.6ms/1.2Pa, 32x=53.2ms/0.9Pa, 64x=104.4ms/0.5Pa
25 const uint8_t OVERSAMPLING_PRESSURE = 32;
26 const uint8_t OVERSAMPLING_TEMPERATURE = 8;
28 uint8_t oversampleToRegVal(const uint8_t oversamples) const;
29 int32_t oversampleToScaleFactor(const uint8_t oversamples) const;
30 float m_temperatureLast; // last uncompensated temperature value
32 struct tagCalibrationData
34 int16_t c0;
35 int16_t c1;
36 int32_t c00;
37 int32_t c10;
38 int16_t c01;
39 int16_t c11;
40 int16_t c20;
41 int16_t c21;
42 int16_t c30;
43 } m_calib; // calibration data, if initialized