mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
[VTX] vtxTable factory flag and full integration of vtxTable (#8380)
Moved vtxtable frequency mode implementation into `vtx_common.c`. This makes the implementation available for all vtx types and allows for some code deduplication (see point below) Removed band and channel tracking from tramp and rtc6705. The hardware underlying both only support frequency mode and the tracking is now done in `vtx_common.c` using the new factory flag. Deleted vtxStringXXX. to continue supporting builds without `USE_VTX_TABLE`, new infrastructure was created in `drivers/vtx_table.c`, which loads fixed tables into vtxTableXXX when built witout `USE_VTX_TABLE`. Individual vtx implementations no longer need to load any band/channel tables. They only need to load their individual power tables when built without `USE_VTX_TABLE`. Additionally this allows for the next point: Fully integrated vtxTableXXX and removed the old and no longer needed indirection of frequency and power tables in `vtxDevice_t`. Removed VTX_SETTINGS_* constants from `vtx_common.h` and replaced them with the vtxtable equivalent. rtc6705 implementation now uses power values from vtxtable instead of using indices directly. It also stops using index 0. This makes it consistent with other vtx implementations and is more user configurable. It also cleans up `telemetry\srxl.c` which had to have a special case for rtc6705. Finally, frequency entries in the vtxtable can now be marked as empty by setting their frequency to 0. Betaflight will never allow a blocked channel to be selected. This is useful for vtxtable index mode (FACTORY flag set) where manufacturer-defined bands can be truncated to ensure compliance with local laws and regulations.
This commit is contained in:
parent
9abf63a0b0
commit
7cb34205b3
29 changed files with 516 additions and 591 deletions
|
@ -2447,8 +2447,7 @@ static void cliVtx(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
// FIXME Use VTX API to get max
|
||||
if (val >= 0 && val <= VTX_SETTINGS_MAX_BAND) {
|
||||
if (val >= 0 && val <= vtxTableBandCount) {
|
||||
cac->band = val;
|
||||
validArgumentCount++;
|
||||
}
|
||||
|
@ -2456,8 +2455,7 @@ static void cliVtx(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
// FIXME Use VTX API to get max
|
||||
if (val >= 0 && val <= VTX_SETTINGS_MAX_CHANNEL) {
|
||||
if (val >= 0 && val <= vtxTableChannelCount) {
|
||||
cac->channel = val;
|
||||
validArgumentCount++;
|
||||
}
|
||||
|
@ -2465,8 +2463,7 @@ static void cliVtx(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
// FIXME Use VTX API to get max
|
||||
if (val >= 0 && val < VTX_SETTINGS_POWER_COUNT) {
|
||||
if (val >= 0 && val < vtxTablePowerLevels) {
|
||||
cac->power= val;
|
||||
validArgumentCount++;
|
||||
}
|
||||
|
@ -2497,11 +2494,12 @@ static void cliVtx(char *cmdline)
|
|||
|
||||
#ifdef USE_VTX_TABLE
|
||||
|
||||
static char *formatVtxTableBandFrequency(const uint16_t *frequency, int channels)
|
||||
static char *formatVtxTableBandFrequency(const bool isFactory, const uint16_t *frequency, int channels)
|
||||
{
|
||||
static char freqbuf[5 * VTX_TABLE_MAX_CHANNELS + 1];
|
||||
static char freqbuf[5 * VTX_TABLE_MAX_CHANNELS + 8 + 1];
|
||||
char freqtmp[5 + 1];
|
||||
freqbuf[0] = 0;
|
||||
strcat(freqbuf, isFactory ? " FACTORY" : " CUSTOM ");
|
||||
for (int channel = 0; channel < channels; channel++) {
|
||||
tfp_sprintf(freqtmp, " %4d", frequency[channel]);
|
||||
strcat(freqbuf, freqtmp);
|
||||
|
@ -2528,11 +2526,11 @@ static const char *printVtxTableBand(dumpFlags_t dumpMask, int band, const vtxTa
|
|||
}
|
||||
}
|
||||
headingStr = cliPrintSectionHeading(dumpMask, !equalsDefault, headingStr);
|
||||
char *freqbuf = formatVtxTableBandFrequency(defaultConfig->frequency[band], defaultConfig->channels);
|
||||
char *freqbuf = formatVtxTableBandFrequency(defaultConfig->isFactoryBand[band], defaultConfig->frequency[band], defaultConfig->channels);
|
||||
cliDefaultPrintLinef(dumpMask, equalsDefault, fmt, band + 1, defaultConfig->bandNames[band], defaultConfig->bandLetters[band], freqbuf);
|
||||
}
|
||||
|
||||
char *freqbuf = formatVtxTableBandFrequency(currentConfig->frequency[band], currentConfig->channels);
|
||||
char *freqbuf = formatVtxTableBandFrequency(currentConfig->isFactoryBand[band], currentConfig->frequency[band], currentConfig->channels);
|
||||
cliDumpPrintLinef(dumpMask, equalsDefault, fmt, band + 1, currentConfig->bandNames[band], currentConfig->bandLetters[band], freqbuf);
|
||||
return headingStr;
|
||||
}
|
||||
|
@ -2817,8 +2815,20 @@ static void cliVtxTable(char *cmdline)
|
|||
uint16_t bandfreq[VTX_TABLE_MAX_CHANNELS];
|
||||
int channel = 0;
|
||||
int channels = vtxTableConfigMutable()->channels;
|
||||
bool isFactory = false;
|
||||
|
||||
for (channel = 0; channel < channels && (tok = strtok_r(NULL, " ", &saveptr)); channel++) {
|
||||
if (channel == 0 && !isdigit(tok[0])) {
|
||||
channel -= 1;
|
||||
if (strcasecmp(tok, "FACTORY") == 0) {
|
||||
isFactory = true;
|
||||
} else if (strcasecmp(tok, "CUSTOM") == 0) {
|
||||
isFactory = false;
|
||||
} else {
|
||||
cliPrintErrorLinef("INVALID FACTORY FLAG %s (EXPECTED FACTORY OR CUSTOM)", tok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int freq = atoi(tok);
|
||||
if (freq < 0) {
|
||||
cliPrintErrorLinef("INVALID FREQUENCY %s", tok);
|
||||
|
@ -2841,6 +2851,7 @@ static void cliVtxTable(char *cmdline)
|
|||
for (int i = 0; i < channel; i++) {
|
||||
vtxTableConfigMutable()->frequency[band][i] = bandfreq[i];
|
||||
}
|
||||
vtxTableConfigMutable()->isFactoryBand[band] = isFactory;
|
||||
} else {
|
||||
// Bad subcommand
|
||||
cliPrintErrorLinef("INVALID SUBCOMMAND %s", tok);
|
||||
|
@ -5999,7 +6010,7 @@ const clicmd_t cmdTable[] = {
|
|||
#endif
|
||||
#endif
|
||||
#ifdef USE_VTX_TABLE
|
||||
CLI_COMMAND_DEF("vtxtable", "vtx frequency able", "<band> <bandname> <bandletter> <freq> ... <freq>\r\n", cliVtxTable),
|
||||
CLI_COMMAND_DEF("vtxtable", "vtx frequency able", "<band> <bandname> <bandletter> [FACTORY|CUSTOM] <freq> ... <freq>\r\n", cliVtxTable),
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue