From f543daa8baf158b4c91c3e44ea1c1c8ec8a861bb Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Wed, 31 Jul 2019 21:23:18 -0400 Subject: [PATCH] Fix vtx_freq default value when USE_VTX_TABLES is defined When a `vtxDevice` was active (like if `USE_VTX_RTC6705` is defined for the target) then the initialization logic would try to look up the frequency based on the band/channel and update the `vtx_freq` setting. The problem is that initially the `vtxtable` is not defined so the frequency lookup fails and returns 0. This resulted in a defaults difference since the default value was 5740 which would have matched the default band and channel if the "standard" bands/channels were set up with `vtxtable`. So instead set the default value to 0 unless legacy built-in frequencies are used (`USE_VTX_TABLES` not defined). --- src/main/io/vtx.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/io/vtx.c b/src/main/io/vtx.c index c1a110114..f57c02d7d 100644 --- a/src/main/io/vtx.c +++ b/src/main/io/vtx.c @@ -47,16 +47,21 @@ #include "vtx.h" -PG_REGISTER_WITH_RESET_TEMPLATE(vtxSettingsConfig_t, vtxSettingsConfig, PG_VTX_SETTINGS_CONFIG, 0); - -PG_RESET_TEMPLATE(vtxSettingsConfig_t, vtxSettingsConfig, - .band = VTX_TABLE_DEFAULT_BAND, - .channel = VTX_TABLE_DEFAULT_CHANNEL, - .power = VTX_TABLE_DEFAULT_POWER, - .freq = VTX_TABLE_DEFAULT_FREQ, - .pitModeFreq = VTX_TABLE_DEFAULT_PITMODE_FREQ, - .lowPowerDisarm = VTX_LOW_POWER_DISARM_OFF, - ); +PG_REGISTER_WITH_RESET_FN(vtxSettingsConfig_t, vtxSettingsConfig, PG_VTX_SETTINGS_CONFIG, 0); + +void pgResetFn_vtxSettingsConfig(vtxSettingsConfig_t *vtxSettingsConfig) +{ + vtxSettingsConfig->band = VTX_TABLE_DEFAULT_BAND; + vtxSettingsConfig->channel = VTX_TABLE_DEFAULT_CHANNEL; + vtxSettingsConfig->power = VTX_TABLE_DEFAULT_POWER; +#ifdef USE_VTX_TABLE + vtxSettingsConfig->freq = 0; +#else + vtxSettingsConfig->freq = VTX_TABLE_DEFAULT_FREQ; +#endif + vtxSettingsConfig->pitModeFreq = VTX_TABLE_DEFAULT_PITMODE_FREQ; + vtxSettingsConfig->lowPowerDisarm = VTX_LOW_POWER_DISARM_OFF; +} typedef enum { VTX_PARAM_POWER = 0, -- 2.11.4.GIT