VTX Pit Mode control conflict resolved, Tx switch vs menues, (#5621)

This commit is contained in:
Anders Höglund 2018-04-04 16:03:12 +02:00 committed by Michael Keller
parent a3a4f5586f
commit 21e77dd66d
2 changed files with 30 additions and 12 deletions

View File

@ -150,10 +150,17 @@ void spektrumHandleVtxControl(uint32_t vtxCntrl)
// ############ VTX_CONTROL task ############# // ############ VTX_CONTROL task #############
void spektrumVtxControl(void) void spektrumVtxControl(void)
{ {
static uint32_t prevVtxControl =0;
uint32_t vtxControl;
// Check for invalid VTX ctrl frames // Check for invalid VTX ctrl frames
if ((vtxControl_ipc & SPEKTRUM_VTX_CONTROL_FRAME_MASK) != SPEKTRUM_VTX_CONTROL_FRAME) return; if ((vtxControl_ipc & SPEKTRUM_VTX_CONTROL_FRAME_MASK) != SPEKTRUM_VTX_CONTROL_FRAME) return;
uint32_t vtxControl = vtxControl_ipc; vtxControl = vtxControl_ipc;
vtxControl_ipc = 0;
if (prevVtxControl == vtxControl) return;
prevVtxControl = vtxControl;
spektrumVtx_t vtx = { spektrumVtx_t vtx = {
.pitMode = (vtxControl & SPEKTRUM_VTX_PIT_MODE_MASK) >> SPEKTRUM_VTX_PIT_MODE_SHIFT, .pitMode = (vtxControl & SPEKTRUM_VTX_PIT_MODE_MASK) >> SPEKTRUM_VTX_PIT_MODE_SHIFT,
@ -201,11 +208,12 @@ void spektrumVtxControl(void)
} }
// Everyone seems to agree on what PIT ON/OFF means // Everyone seems to agree on what PIT ON/OFF means
uint8_t currentPitMode = 0; uint8_t currentPitMode = 0;
vtxCommonGetPitMode(vtxDevice, &currentPitMode); if (vtxCommonGetPitMode(vtxDevice, &currentPitMode)) {
if (currentPitMode != vtx.pitMode) { if (currentPitMode != vtx.pitMode) {
vtxCommonSetPitMode(vtxDevice, vtx.pitMode); vtxCommonSetPitMode(vtxDevice, vtx.pitMode);
} }
} }
}
if (memcmp(&prevSettings,&newSettings,sizeof(vtxSettingsConfig_t))) { if (memcmp(&prevSettings,&newSettings,sizeof(vtxSettingsConfig_t))) {
vtxSettingsConfigMutable()->band = newSettings.band; vtxSettingsConfigMutable()->band = newSettings.band;

View File

@ -164,8 +164,17 @@ static bool vtxProcessPower(vtxDevice_t *vtxDevice)
static bool vtxProcessPitMode(vtxDevice_t *vtxDevice) static bool vtxProcessPitMode(vtxDevice_t *vtxDevice)
{ {
uint8_t pitOnOff; uint8_t pitOnOff;
bool currPmSwitchState;
static bool prevPmSwitchState = false;
if (!ARMING_FLAG(ARMED) && vtxCommonGetPitMode(vtxDevice, &pitOnOff)) { if (!ARMING_FLAG(ARMED) && vtxCommonGetPitMode(vtxDevice, &pitOnOff)) {
if (IS_RC_MODE_ACTIVE(BOXVTXPITMODE)) { currPmSwitchState = IS_RC_MODE_ACTIVE(BOXVTXPITMODE);
if (currPmSwitchState != prevPmSwitchState) {
prevPmSwitchState = currPmSwitchState;
if (currPmSwitchState) {
#if defined(VTX_SETTINGS_FREQCMD) #if defined(VTX_SETTINGS_FREQCMD)
if (vtxSettingsConfig()->pitModeFreq) { if (vtxSettingsConfig()->pitModeFreq) {
return false; return false;
@ -176,6 +185,7 @@ static bool vtxProcessPitMode(vtxDevice_t *vtxDevice)
vtxCommonSetPitMode(vtxDevice, true); vtxCommonSetPitMode(vtxDevice, true);
return true; return true;
} }
}
} else { } else {
if (pitOnOff) { if (pitOnOff) {
vtxCommonSetPitMode(vtxDevice, false); vtxCommonSetPitMode(vtxDevice, false);