mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 00:35:34 +03:00
Merge pull request #5624 from iNavFlight/dzikuvx-vtx-band-channel-change-via-functions
Allow to change VTX band and channel via global functions
This commit is contained in:
commit
c69cad69d1
3 changed files with 28 additions and 8 deletions
|
@ -26,6 +26,8 @@ _Global Functions_ (abbr. GF) are a mechanism allowing to override certain fligh
|
|||
| 5 | INVERT_PITCH | Inverts PITCH axis input for PID/PIFF controller |
|
||||
| 6 | INVERT_YAW | Inverts YAW axis input for PID/PIFF controller |
|
||||
| 7 | OVERRIDE_THROTTLE | Override throttle value that is fed to the motors by mixer. Operand is scaled in us. `1000` means throttle cut, `1500` means half throttle |
|
||||
| 8 | SET_VTX_BAND | Sets VTX band. Accepted values are `1-5` |
|
||||
| 8 | SET_VTX_CHANNEL | Sets VTX channel. Accepted values are `1-8` |
|
||||
|
||||
## Flags
|
||||
|
||||
|
|
|
@ -98,6 +98,22 @@ void globalFunctionsProcess(int8_t functionId) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case GLOBAL_FUNCTION_ACTION_SET_VTX_BAND:
|
||||
if (conditionValue && !previousValue) {
|
||||
vtxDeviceCapability_t vtxDeviceCapability;
|
||||
if (vtxCommonGetDeviceCapability(vtxCommonDevice(), &vtxDeviceCapability)) {
|
||||
vtxSettingsConfigMutable()->band = constrain(globalFunctionsStates[functionId].value, VTX_SETTINGS_MIN_BAND, VTX_SETTINGS_MAX_BAND);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GLOBAL_FUNCTION_ACTION_SET_VTX_CHANNEL:
|
||||
if (conditionValue && !previousValue) {
|
||||
vtxDeviceCapability_t vtxDeviceCapability;
|
||||
if (vtxCommonGetDeviceCapability(vtxCommonDevice(), &vtxDeviceCapability)) {
|
||||
vtxSettingsConfigMutable()->channel = constrain(globalFunctionsStates[functionId].value, VTX_SETTINGS_MIN_CHANNEL, VTX_SETTINGS_MAX_CHANNEL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GLOBAL_FUNCTION_ACTION_INVERT_ROLL:
|
||||
if (conditionValue) {
|
||||
GLOBAL_FUNCTION_FLAG_ENABLE(GLOBAL_FUNCTION_FLAG_OVERRIDE_INVERT_ROLL);
|
||||
|
|
|
@ -29,14 +29,16 @@
|
|||
#define MAX_GLOBAL_FUNCTIONS 8
|
||||
|
||||
typedef enum {
|
||||
GLOBAL_FUNCTION_ACTION_OVERRIDE_ARMING_SAFETY = 0,
|
||||
GLOBAL_FUNCTION_ACTION_OVERRIDE_THROTTLE_SCALE,
|
||||
GLOBAL_FUNCTION_ACTION_SWAP_ROLL_YAW,
|
||||
GLOBAL_FUNCTION_ACTION_SET_VTX_POWER_LEVEL,
|
||||
GLOBAL_FUNCTION_ACTION_INVERT_ROLL,
|
||||
GLOBAL_FUNCTION_ACTION_INVERT_PITCH,
|
||||
GLOBAL_FUNCTION_ACTION_INVERT_YAW,
|
||||
GLOBAL_FUNCTION_ACTION_OVERRIDE_THROTTLE,
|
||||
GLOBAL_FUNCTION_ACTION_OVERRIDE_ARMING_SAFETY = 0, // 0
|
||||
GLOBAL_FUNCTION_ACTION_OVERRIDE_THROTTLE_SCALE, // 1
|
||||
GLOBAL_FUNCTION_ACTION_SWAP_ROLL_YAW, // 2
|
||||
GLOBAL_FUNCTION_ACTION_SET_VTX_POWER_LEVEL, // 3
|
||||
GLOBAL_FUNCTION_ACTION_INVERT_ROLL, // 4
|
||||
GLOBAL_FUNCTION_ACTION_INVERT_PITCH, // 5
|
||||
GLOBAL_FUNCTION_ACTION_INVERT_YAW, // 6
|
||||
GLOBAL_FUNCTION_ACTION_OVERRIDE_THROTTLE, // 7
|
||||
GLOBAL_FUNCTION_ACTION_SET_VTX_BAND, // 8
|
||||
GLOBAL_FUNCTION_ACTION_SET_VTX_CHANNEL, // 9
|
||||
GLOBAL_FUNCTION_ACTION_LAST
|
||||
} globalFunctionActions_e;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue