2 * This file is part of INAV.
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 INAV. If not, see <http://www.gnu.org/licenses/>.
22 #ifdef USE_SERIAL_GIMBAL
26 #include "config/feature.h"
27 #include "common/time.h"
34 GIMBAL_DEV_UNSUPPORTED
= 0,
36 GIMBAL_DEV_UNKNOWN
=0xFF
40 struct gimbalVTable_s
;
42 typedef struct gimbalDevice_s
{
43 const struct gimbalVTable_s
*vTable
;
44 int16_t currentPanPWM
;
47 // {set,get}BandAndChannel: band and channel are 1 origin
48 // {set,get}PowerByIndex: 0 = Power OFF, 1 = device dependent
49 // {set,get}PitMode: 0 = OFF, 1 = ON
51 typedef struct gimbalVTable_s
{
52 void (*process
)(gimbalDevice_t
*gimbalDevice
, timeUs_t currentTimeUs
);
53 gimbalDevType_e (*getDeviceType
)(const gimbalDevice_t
*gimbalDevice
);
54 bool (*isReady
)(const gimbalDevice_t
*gimbalDevice
);
55 bool (*hasHeadTracker
)(const gimbalDevice_t
*gimbalDevice
);
56 int16_t (*getGimbalPanPWM
)(const gimbalDevice_t
*gimbalDevice
);
60 typedef struct gimbalConfig_s
{
70 PG_DECLARE(gimbalConfig_t
, gimbalConfig
);
73 GIMBAL_MODE_FOLLOW
= 0,
74 GIMBAL_MODE_TILT_LOCK
= (1<<0),
75 GIMBAL_MODE_ROLL_LOCK
= (1<<1),
76 GIMBAL_MODE_PAN_LOCK
= (1<<2),
79 #define GIMBAL_MODE_DEFAULT GIMBAL_MODE_FOLLOW
80 #define GIMBAL_MODE_TILT_ROLL_LOCK (GIMBAL_MODE_TILT_LOCK | GIMBAL_MODE_ROLL_LOCK)
81 #define GIMBAL_MODE_PAN_TILT_ROLL_LOCK (GIMBAL_MODE_TILT_LOCK | GIMBAL_MODE_ROLL_LOCK | GIMBAL_MODE_PAN_LOCK)
83 void gimbalCommonInit(void);
84 void gimbalCommonSetDevice(gimbalDevice_t
*gimbalDevice
);
85 gimbalDevice_t
*gimbalCommonDevice(void);
88 void gimbalCommonProcess(gimbalDevice_t
*gimbalDevice
, timeUs_t currentTimeUs
);
89 gimbalDevType_e
gimbalCommonGetDeviceType(gimbalDevice_t
*gimbalDevice
);
90 bool gimbalCommonIsReady(gimbalDevice_t
*gimbalDevice
);
93 void taskUpdateGimbal(timeUs_t currentTimeUs
);
95 bool gimbalCommonIsEnabled(void);
96 bool gimbalCommonHtrkIsEnabled(void);
98 int16_t gimbalCommonGetPanPwm(const gimbalDevice_t
*gimbalDevice
);