Merge pull request #4542 from codecae/vtx_low_power_disarm_cms_fix

SA CMS fix for vtx_low_power_disarm
This commit is contained in:
Michael Keller 2017-11-12 00:33:21 +13:00 committed by GitHub
commit 9a11263cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 9 deletions

View File

@ -71,34 +71,36 @@ void vtxInit(void)
}
}
static void vtxProcessBandAndChannel(timeUs_t currentTimeUs) {
static bool vtxProcessBandAndChannel(void) {
if(!ARMING_FLAG(ARMED)) {
uint8_t vtxBand;
uint8_t vtxChan;
if (vtxCommonGetBandAndChannel(&vtxBand, &vtxChan)) {
if (vtxSettingsConfig()->band != vtxBand || vtxSettingsConfig()->channel != vtxChan) {
vtxCommonSetBandAndChannel(vtxSettingsConfig()->band, vtxSettingsConfig()->channel);
vtxCommonProcess(currentTimeUs);
return true;
}
}
}
return false;
}
#if defined(VTX_SETTINGS_FREQCMD)
static void vtxProcessFrequency(timeUs_t currentTimeUs) {
static bool vtxProcessFrequency(void) {
if(!ARMING_FLAG(ARMED)) {
uint16_t vtxFreq;
if (vtxCommonGetFrequency(&vtxFreq)) {
if (vtxSettingsConfig()->freq != vtxFreq) {
vtxCommonSetFrequency(vtxSettingsConfig()->freq);
vtxCommonProcess(currentTimeUs);
return true;
}
}
}
return false;
}
#endif
static void vtxProcessPower(timeUs_t currentTimeUs) {
static bool vtxProcessPower(void) {
uint8_t vtxPower;
uint8_t newPower = vtxSettingsConfig()->power;
if (vtxCommonGetPowerIndex(&vtxPower)) {
@ -107,15 +109,17 @@ static void vtxProcessPower(timeUs_t currentTimeUs) {
}
if (vtxPower != newPower) {
vtxCommonSetPowerByIndex(newPower);
vtxCommonProcess(currentTimeUs);
return true;
}
}
return false;
}
void vtxProcessSchedule(timeUs_t currentTimeUs)
{
static timeUs_t lastCycleTimeUs;
static uint8_t scheduleIndex;
bool vtxUpdatePending = false;
if (vtxCommonDeviceRegistered()) {
const uint8_t currentSchedule = vtxParamSchedule[scheduleIndex];
@ -124,15 +128,15 @@ void vtxProcessSchedule(timeUs_t currentTimeUs)
switch (currentSchedule) {
case VTX_PARAM_BANDCHAN:
if (vtxSettingsConfig()->band) {
vtxProcessBandAndChannel(currentTimeUs);
vtxUpdatePending = vtxProcessBandAndChannel();
#if defined(VTX_SETTINGS_FREQCMD)
} else {
vtxProcessFrequency(currentTimeUs);
vtxUpdatePending = vtxProcessFrequency();
#endif
}
break;
case VTX_PARAM_POWER:
vtxProcessPower(currentTimeUs);
vtxUpdatePending = vtxProcessPower();
break;
default:
break;
@ -140,6 +144,9 @@ void vtxProcessSchedule(timeUs_t currentTimeUs)
lastCycleTimeUs = currentTimeUs;
scheduleIndex = (scheduleIndex + 1) % vtxParamScheduleCount;
}
if (!ARMING_FLAG(ARMED) || vtxUpdatePending) {
vtxCommonProcess(currentTimeUs);
}
}
}