Don't handle non-MSP characters on VTX MSP port (#14091)
[betaflight.git] / src / main / drivers / barometer / barometer_virtual.c
blobe5ca2564ec1cf78fbd95188243b4d944cf271111
1 /*
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)
8 * any later version.
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/>.
21 #include <stdbool.h>
22 #include <stdint.h>
24 #include "platform.h"
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)
38 UNUSED(baro);
40 return true;
43 static bool virtualBaroReadGet(baroDev_t *baro)
45 UNUSED(baro);
47 return true;
50 static void virtualBaroCalculate(int32_t *pressure, int32_t *temperature)
52 if (pressure)
53 *pressure = virtualPressure;
54 if (temperature)
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;
83 return true;
85 #endif // USE_VIRTUAL_BARO