Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / pitotmeter / pitotmeter_fake.c
blobf8302a38d0cac3f9a5173c3fff71cd1a179f16a0
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 #include "build/build_config.h"
25 #include "common/utils.h"
27 #include "drivers/pitotmeter/pitotmeter.h"
28 #include "drivers/pitotmeter/pitotmeter_fake.h"
30 #ifdef USE_PITOT_FAKE
31 static float fakePressure;
32 static float fakeTemperature;
33 static float fakeAirspeed;
35 static bool fakePitotStart(pitotDev_t *pitot)
37 UNUSED(pitot);
38 return true;
41 void fakePitotSet(float pressure, float temperature)
43 fakePressure = pressure;
44 fakeTemperature = temperature;
47 void fakePitotSetAirspeed(float airSpeed)
49 fakeAirspeed = airSpeed;
52 float fakePitotGetAirspeed(void)
54 return fakeAirspeed;
57 bool fakePitotRead(pitotDev_t *pitot)
59 pitot->calculate(pitot, &fakePressure, &fakeTemperature);
60 return true;
63 static void fakePitotCalculate(pitotDev_t *pitot, float *pressure, float *temperature)
65 UNUSED(pitot);
66 if (pressure)
67 *pressure = fakePressure; // Pa
68 if (temperature)
69 *temperature = fakeTemperature; // K
72 bool fakePitotDetect(pitotDev_t *pitot)
74 fakePressure = 0; // 0Pa
75 fakeTemperature = 273; // 0C
77 pitot->delay = 10000;
78 pitot->calibThreshold = 0.00001f;
79 pitot->start = fakePitotStart;
80 pitot->get = fakePitotRead;
81 pitot->calculate = fakePitotCalculate;
82 return true;
84 #endif