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"
34 static int32_t virtualPressure
;
35 static int32_t virtualTemperature
;
38 static bool virtualBaroStart(baroDev_t
*baro
)
45 static bool virtualBaroReadGet(baroDev_t
*baro
)
52 static void virtualBaroCalculate(int32_t *pressure
, int32_t *temperature
)
55 *pressure
= virtualPressure
;
57 *temperature
= virtualTemperature
;
60 void virtualBaroSet(int32_t pressure
, int32_t temperature
)
62 virtualPressure
= pressure
;
63 virtualTemperature
= temperature
;
66 bool virtualBaroDetect(baroDev_t
*baro
)
68 virtualPressure
= 101325; // pressure in Pa (0m MSL)
69 virtualTemperature
= 2500; // temperature in 0.01 C = 25 deg
71 // these are dummy as temperature is measured as part of pressure
72 baro
->combined_read
= true;
73 baro
->ut_delay
= 10000;
74 baro
->get_ut
= virtualBaroReadGet
;
75 baro
->read_ut
= virtualBaroReadGet
;
76 baro
->start_ut
= virtualBaroStart
;
78 // only _up part is executed, and gets both temperature and pressure
79 baro
->up_delay
= 10000;
80 baro
->start_up
= virtualBaroStart
;
81 baro
->read_up
= virtualBaroReadGet
;
82 baro
->get_up
= virtualBaroReadGet
;
83 baro
->calculate
= virtualBaroCalculate
;
87 #endif // USE_VIRTUAL_BARO