Merge pull request #10558 from iNavFlight/MrD_Correct-comments-on-OSD-symbols
[inav.git] / src / main / drivers / barometer / barometer_fake.c
blobbcab0ce992562e3dc845c9a25db6421706f00220
1 /*
2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
18 #include <stdbool.h>
19 #include <stdint.h>
21 #include <platform.h>
23 #ifdef USE_FAKE_BARO
25 #include "common/utils.h"
26 #include "drivers/barometer/barometer.h"
27 #include "drivers/barometer/barometer_fake.h"
30 static int32_t fakePressure;
31 static int32_t fakeTemperature;
34 static bool fakeBaroStartGet(baroDev_t * baro)
36 UNUSED(baro);
37 return true;
40 static bool fakeBaroCalculate(baroDev_t * baro, int32_t *pressure, int32_t *temperature)
42 UNUSED(baro);
43 if (pressure)
44 *pressure = fakePressure;
45 if (temperature)
46 *temperature = fakeTemperature;
47 return true;
50 void fakeBaroSet(int32_t pressure, int32_t temperature)
52 fakePressure = pressure;
53 fakeTemperature = temperature;
56 bool fakeBaroDetect(baroDev_t *baro)
58 fakePressure = 0; // pressure in Pa (0m MSL)
59 fakeTemperature = 0; // temperature in 0.01 C = 25 deg
61 // these are dummy as temperature is measured as part of pressure
62 baro->ut_delay = 0;
63 baro->get_ut = fakeBaroStartGet;
64 baro->start_ut = fakeBaroStartGet;
66 // only _up part is executed, and gets both temperature and pressure
67 baro->up_delay = 1000;
68 baro->start_up = fakeBaroStartGet;
69 baro->get_up = fakeBaroStartGet;
70 baro->calculate = fakeBaroCalculate;
72 return true;
74 #endif // USE_FAKE_BARO