Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / sensors / opflow.h
blobafe94ec79ac8882fc3f21ca31eafd931dcd35b71
1 /*
2 * This file is part of INAV Project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 * You can obtain one at http://mozilla.org/MPL/2.0/.
8 * Alternatively, the contents of this file may be used under the terms
9 * of the GNU General Public License Version 3, as described below:
11 * This file is free software: you may copy, redistribute and/or modify
12 * it under the terms of the GNU General Public License as published by the
13 * Free Software Foundation, either version 3 of the License, or (at your
14 * option) any later version.
16 * This file is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
19 * Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see http://www.gnu.org/licenses/.
25 #pragma once
27 #include <stdint.h>
28 #include "config/parameter_group.h"
29 #include "drivers/opflow/opflow.h"
31 typedef enum {
32 OPFLOW_NONE = 0,
33 OPFLOW_CXOF = 1,
34 OPFLOW_MSP = 2,
35 OPFLOW_FAKE = 3,
36 } opticalFlowSensor_e;
38 typedef enum {
39 OPFLOW_QUALITY_INVALID,
40 OPFLOW_QUALITY_VALID
41 } opflowQuality_e;
43 typedef struct opticalFlowConfig_s {
44 uint8_t opflow_hardware;
45 uint8_t opflow_align;
46 float opflow_scale; // Scaler value to convert between raw sensor units to [deg/s]
47 } opticalFlowConfig_t;
49 PG_DECLARE(opticalFlowConfig_t, opticalFlowConfig);
51 typedef struct opflow_s {
52 opflowDev_t dev;
54 opflowQuality_e flowQuality;
55 timeUs_t lastValidUpdate;
56 bool isHwHealty;
57 float flowRate[2]; // optical flow angular rate in rad/sec measured about the X and Y body axis
58 float bodyRate[2]; // body inertial angular rate in rad/sec measured about the X and Y body axis
60 float gyroBodyRateAcc[2];
61 timeUs_t gyroBodyRateTimeUs;
63 uint8_t rawQuality;
64 } opflow_t;
66 extern opflow_t opflow;
68 void opflowGyroUpdateCallback(timeUs_t gyroUpdateDeltaUs);
69 bool opflowInit(void);
70 void opflowUpdate(timeUs_t currentTimeUs);
71 bool opflowIsHealthy(void);
72 void opflowStartCalibration(void);