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/>.
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
)
40 static bool fakeBaroCalculate(baroDev_t
* baro
, int32_t *pressure
, int32_t *temperature
)
44 *pressure
= fakePressure
;
46 *temperature
= fakeTemperature
;
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
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
;
74 #endif // USE_FAKE_BARO