1
+ /*
2
+ * This file is part of INAV.
3
+ *
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.
8
+ *
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.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with INAV. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include "platform.h"
21
+
22
+ #ifdef USE_SERIAL_GIMBAL
23
+
24
+ #include <stdint.h>
25
+
26
+ #include "config/feature.h"
27
+ #include "common/time.h"
28
+
29
+ #ifdef __cplusplus
30
+ extern "C" {
31
+ #endif
32
+
33
+ typedef enum {
34
+ GIMBAL_DEV_UNSUPPORTED = 0 ,
35
+ GIMBAL_DEV_SERIAL ,
36
+ GIMBAL_DEV_UNKNOWN = 0xFF
37
+ } gimbalDevType_e ;
38
+
39
+
40
+ struct gimbalVTable_s ;
41
+
42
+ typedef struct gimbalDevice_s {
43
+ const struct gimbalVTable_s * vTable ;
44
+ } gimbalDevice_t ;
45
+
46
+ // {set,get}BandAndChannel: band and channel are 1 origin
47
+ // {set,get}PowerByIndex: 0 = Power OFF, 1 = device dependent
48
+ // {set,get}PitMode: 0 = OFF, 1 = ON
49
+
50
+ typedef struct gimbalVTable_s {
51
+ void (* process )(gimbalDevice_t * gimbalDevice , timeUs_t currentTimeUs );
52
+ gimbalDevType_e (* getDeviceType )(const gimbalDevice_t * gimbalDevice );
53
+ bool (* isReady )(const gimbalDevice_t * gimbalDevice );
54
+ bool (* hasHeadTracker )(const gimbalDevice_t * gimbalDevice );
55
+ } gimbalVTable_t ;
56
+
57
+
58
+ typedef struct gimbalConfig_s {
59
+ uint8_t panChannel ;
60
+ uint8_t tiltChannel ;
61
+ uint8_t rollChannel ;
62
+ uint8_t sensitivity ;
63
+ } gimbalConfig_t ;
64
+
65
+ PG_DECLARE (gimbalConfig_t , gimbalConfig );
66
+
67
+ typedef enum {
68
+ GIMBAL_MODE_FOLLOW = 0 ,
69
+ GIMBAL_MODE_TILT_LOCK = (1 <<0 ),
70
+ GIMBAL_MODE_ROLL_LOCK = (1 <<1 ),
71
+ GIMBAL_MODE_PAN_LOCK = (1 <<2 ),
72
+ } gimbal_htk_mode_e ;
73
+
74
+ #define GIMBAL_MODE_DEFAULT GIMBAL_MODE_FOLLOW
75
+ #define GIMBAL_MODE_TILT_ROLL_LOCK (GIMBAL_MODE_TILT_LOCK | GIMBAL_MODE_ROLL_LOCK)
76
+ #define GIMBAL_MODE_PAN_TILT_ROLL_LOCK (GIMBAL_MODE_TILT_LOCK | GIMBAL_MODE_ROLL_LOCK | GIMBAL_MODE_PAN_LOCK)
77
+
78
+ void gimbalCommonInit (void );
79
+ void gimbalCommonSetDevice (gimbalDevice_t * gimbalDevice );
80
+ gimbalDevice_t * gimbalCommonDevice (void );
81
+
82
+ // VTable functions
83
+ void gimbalCommonProcess (gimbalDevice_t * gimbalDevice , timeUs_t currentTimeUs );
84
+ gimbalDevType_e gimbalCommonGetDeviceType (gimbalDevice_t * gimbalDevice );
85
+ bool gimbalCommonIsReady (gimbalDevice_t * gimbalDevice );
86
+
87
+
88
+ void taskUpdateGimbal (timeUs_t currentTimeUs );
89
+
90
+ bool gimbalCommonIsEnabled (void );
91
+ bool gimbalCommonHtrkIsEnabled (void );
92
+
93
+ #ifdef __cplusplus
94
+ }
95
+ #endif
96
+
97
+ #endif
0 commit comments