Merge branch 'master' into abo_stats_pages_auto_swap
[inav.git] / src / main / sensors / pitotmeter.h
blobb7fd3c4ca79c11f55a4e7e7801af39c9f812f940
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 #pragma once
20 #include "config/parameter_group.h"
21 #include "common/filter.h"
22 #include "common/calibration.h"
24 #include "drivers/pitotmeter/pitotmeter.h"
26 typedef enum {
27 PITOT_NONE = 0,
28 PITOT_AUTODETECT = 1,
29 PITOT_MS4525 = 2,
30 PITOT_ADC = 3,
31 PITOT_VIRTUAL = 4,
32 PITOT_FAKE = 5,
33 PITOT_MSP = 6,
34 } pitotSensor_e;
36 #define PITOT_MAX PITOT_FAKE
37 #define PITOT_SAMPLE_COUNT_MAX 48
39 typedef struct pitotmeterConfig_s {
40 uint8_t pitot_hardware; // Pitotmeter hardware to use
41 uint16_t pitot_lpf_milli_hz; // additional LPF to reduce pitot noise in [0.001Hz]
42 float pitot_scale; // scale value
43 } pitotmeterConfig_t;
45 PG_DECLARE(pitotmeterConfig_t, pitotmeterConfig);
47 typedef struct pito_s {
48 pitotDev_t dev;
49 float airSpeed;
51 zeroCalibrationScalar_t zeroCalibration;
52 pt1Filter_t lpfState;
53 timeUs_t lastMeasurementUs;
54 timeMs_t lastSeenHealthyMs;
56 float pressureZero;
57 float pressure;
58 } pitot_t;
60 #ifdef USE_PITOT
62 #define AIR_DENSITY_SEA_LEVEL_15C 1.225f // Air density at sea level and 15 degrees Celsius
63 #define P0 101325.0f // standard pressure [Pa]
65 extern pitot_t pitot;
67 bool pitotInit(void);
68 bool pitotIsCalibrationComplete(void);
69 void pitotStartCalibration(void);
70 void pitotUpdate(void);
71 int32_t pitotCalculateAirSpeed(void);
72 bool pitotIsHealthy(void);
74 #endif