Avionics
Core avionics package for CURE flight computers
Loading...
Searching...
No Matches
Serial_Sim_BMP390.h
Go to the documentation of this file.
1#ifndef SERIAL_SIM_BMP390_H
2#define SERIAL_SIM_BMP390_H
3
4#include "Serial_Sim.h"
5
6#ifndef BMP3_NO_OVERSAMPLING
7#define BMP3_NO_OVERSAMPLING 0x00
8#endif
9
10#ifndef BMP3_OVERSAMPLING_2X
11#define BMP3_OVERSAMPLING_2X 0x01
12#endif
13
14#ifndef BMP3_OVERSAMPLING_4X
15#define BMP3_OVERSAMPLING_4X 0x02
16#endif
17
18#ifndef BMP3_OVERSAMPLING_8X
19#define BMP3_OVERSAMPLING_8X 0x03
20#endif
21
22#ifndef BMP3_OVERSAMPLING_16X
23#define BMP3_OVERSAMPLING_16X 0x04
24#endif
25
26#ifndef BMP3_OVERSAMPLING_32X
27#define BMP3_OVERSAMPLING_32X 0x05
28#endif
29
30#ifndef BMP3_IIR_FILTER_COEFF_3
31#define BMP3_IIR_FILTER_COEFF_3 0x02
32#endif
33
34#ifndef BMP3_ODR_100_HZ
35#define BMP3_ODR_100_HZ 0x01
36#endif
37
38#ifndef BMP3_ODR_50_HZ
39#define BMP3_ODR_50_HZ 0x02
40#endif
41
48public:
50
51 bool begin_SPI(int cs) { return true; } // Mock successful initialization
52 bool begin_I2C(int addr) { return true; } // Mock successful initialization
53 bool begin_I2C() { return true; } // Mock successful initialization
54
55 void setTemperatureOversampling(int oversampling) { temperatureOversampling_ = oversampling; }
56 void setPressureOversampling(int oversampling) { pressureOversampling_ = oversampling; }
57 void setIIRFilterCoeff(int coeff) { iirFilterCoeff_ = coeff; }
58 void setOutputDataRate(int rate) { outputDataRate_ = rate; }
59 void setConversionDelay(int delay) {}
61 bool updateConversion(){return true;}
62
63 float temperature = 0;
64 float pressure = 0;
65
67 // Mock successful reading, update everthing from SerialSim
68 sensors_event_t temp;
69 float pressure;
70 float altitude;
74 this->temperature = temp.temperature;
75 this->pressure = pressure;
76 return true;
77 }
78
79
80 float getAlt(){
81 float alt;
83 return alt;
84 }
85
86 float readAltitude(float seaLevelPressure = 1013.25) {
87 // Mock altitude calculation
88 float alt;
90 return alt;
91 }
92
93 float getPressure(){
94 float pressure;
96 return pressure;
97 }
98
100 sensors_event_t temp;
101 float temp_f;
102
104 temp_f = temp.temperature;
105 return temp_f;
106 }
107
108
109private:
110 int temperatureOversampling_ = BMP3_NO_OVERSAMPLING;
111 int pressureOversampling_ = BMP3_OVERSAMPLING_2X;
112 int iirFilterCoeff_ = BMP3_IIR_FILTER_COEFF_3;
113 int outputDataRate_ = BMP3_ODR_100_HZ;
114
115};
116
117#endif // SERIAL_SIM_BMP390_H
#define BMP3_IIR_FILTER_COEFF_3
#define BMP3_NO_OVERSAMPLING
#define BMP3_ODR_100_HZ
#define BMP3_OVERSAMPLING_2X
void setTemperatureOversampling(int oversampling)
bool begin_I2C(int addr)
void setConversionDelay(int delay)
void setOutputDataRate(int rate)
bool begin_SPI(int cs)
void setPressureOversampling(int oversampling)
void setIIRFilterCoeff(int coeff)
float readAltitude(float seaLevelPressure=1013.25)
void updateTemp(sensors_event_t &temp)
Definition Serial_Sim.h:90
void updateAlt(float &alt)
Definition Serial_Sim.h:82
void updatePres(float &pres)
Definition Serial_Sim.h:86
static SerialSim & getInstance()
Definition Serial_Sim.h:16