Merge pull request #8726 from etracer65/vtx_setting_validation

Reset vtx band/channel/power if outside vtxtable ranges
This commit is contained in:
Michael Keller 2019-08-18 09:42:04 +12:00 committed by GitHub
commit 8230923a14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 2 deletions

View File

@ -56,16 +56,18 @@
#include "io/gps.h"
#include "io/ledstrip.h"
#include "io/serial.h"
#include "io/vtx.h"
#include "osd/osd.h"
#include "pg/beeper.h"
#include "pg/beeper_dev.h"
#include "pg/gyrodev.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/motor.h"
#include "pg/rx.h"
#include "pg/gyrodev.h"
#include "pg/vtx_table.h"
#include "rx/rx.h"
@ -73,8 +75,8 @@
#include "sensors/acceleration.h"
#include "sensors/battery.h"
#include "sensors/gyro.h"
#include "sensors/compass.h"
#include "sensors/gyro.h"
#include "common/sensor_alignment.h"
@ -525,6 +527,23 @@ static void validateAndFixConfig(void)
}
#endif
#if defined(USE_VTX_COMMON) && defined(USE_VTX_TABLE)
// reset vtx band, channel, power if outside range specified by vtxtable
if (vtxSettingsConfig()->channel > vtxTableConfig()->channels) {
vtxSettingsConfigMutable()->channel = 0;
if (vtxSettingsConfig()->band > 0) {
vtxSettingsConfigMutable()->freq = 0; // band/channel determined frequency can't be valid anymore
}
}
if (vtxSettingsConfig()->band > vtxTableConfig()->bands) {
vtxSettingsConfigMutable()->band = 0;
vtxSettingsConfigMutable()->freq = 0; // band/channel determined frequency can't be valid anymore
}
if (vtxSettingsConfig()->power > vtxTableConfig()->powerLevels) {
vtxSettingsConfigMutable()->power = 0;
}
#endif
#if defined(TARGET_VALIDATECONFIG)
targetValidateConfiguration();
#endif