Merge branch 'master' into abo_stats_pages_auto_swap
[inav.git] / src / main / sensors / rangefinder.h
blob568c01ae129dc6c36f045dbe46652073f376258b
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 <stdint.h>
21 #include "config/parameter_group.h"
22 #include "drivers/rangefinder/rangefinder.h"
24 typedef enum {
25 RANGEFINDER_NONE = 0,
26 RANGEFINDER_HCSR04 = 1,
27 RANGEFINDER_SRF10 = 2,
28 RANGEFINDER_HCSR04I2C = 3,
29 RANGEFINDER_VL53L0X = 4,
30 RANGEFINDER_MSP = 5,
31 RANGEFINDER_UNUSED = 6, // Was UIB
32 RANGEFINDER_BENEWAKE = 7,
33 RANGEFINDER_VL53L1X = 8,
34 RANGEFINDER_US42 = 9,
35 } rangefinderType_e;
37 typedef struct rangefinderConfig_s {
38 uint8_t rangefinder_hardware;
39 uint8_t use_median_filtering;
40 } rangefinderConfig_t;
42 PG_DECLARE(rangefinderConfig_t, rangefinderConfig);
44 typedef struct rangefinder_s {
45 rangefinderDev_t dev;
46 float maxTiltCos;
47 int32_t rawAltitude;
48 int32_t calculatedAltitude;
49 timeMs_t lastValidResponseTimeMs;
50 } rangefinder_t;
52 extern rangefinder_t rangefinder;
54 const rangefinderHardwarePins_t * rangefinderGetHardwarePins(void);
56 bool rangefinderInit(void);
58 int32_t rangefinderGetLatestAltitude(void);
59 int32_t rangefinderGetLatestRawAltitude(void);
61 timeDelta_t rangefinderUpdate(void);
62 bool rangefinderProcess(float cosTiltAngle);
63 bool rangefinderIsHealthy(void);