2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
26 #ifdef USE_VIRTUAL_BARO
28 #include "common/utils.h"
30 #include "barometer.h"
31 #include "barometer_virtual.h"
33 static int32_t virtualPressure
;
34 static int32_t virtualTemperature
;
36 static bool virtualBaroStart(baroDev_t
*baro
)
43 static bool virtualBaroReadGet(baroDev_t
*baro
)
50 static void virtualBaroCalculate(int32_t *pressure
, int32_t *temperature
)
53 *pressure
= virtualPressure
;
55 *temperature
= virtualTemperature
;
58 void virtualBaroSet(int32_t pressure
, int32_t temperature
)
60 virtualPressure
= pressure
;
61 virtualTemperature
= temperature
;
64 bool virtualBaroDetect(baroDev_t
*baro
)
66 virtualPressure
= 101325; // pressure in Pa (0m MSL)
67 virtualTemperature
= 2500; // temperature in 0.01 C = 25 deg
69 // these are dummy as temperature is measured as part of pressure
70 baro
->combined_read
= true;
71 baro
->ut_delay
= 10000;
72 baro
->get_ut
= virtualBaroReadGet
;
73 baro
->read_ut
= virtualBaroReadGet
;
74 baro
->start_ut
= virtualBaroStart
;
76 // only _up part is executed, and gets both temperature and pressure
77 baro
->up_delay
= 10000;
78 baro
->start_up
= virtualBaroStart
;
79 baro
->read_up
= virtualBaroReadGet
;
80 baro
->get_up
= virtualBaroReadGet
;
81 baro
->calculate
= virtualBaroCalculate
;
85 #endif // USE_VIRTUAL_BARO