1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

SA CMS fix for vtx_low_power_disarm

This commit is contained in:
Curtis Bangert 2017-11-11 02:03:10 -05:00
parent 0c84506336
commit 85a6389cb6

View file

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