1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +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:
functionpointer 2019-06-17 16:08:36 +02:00
parent 9abf63a0b0
commit 7cb34205b3
29 changed files with 516 additions and 591 deletions

View file

@ -26,12 +26,34 @@
#include "drivers/vtx_common.h"
#ifdef USE_VTX_TABLE
#define VTX_TABLE_MAX_BANDS 8 // Maximum number of bands
#define VTX_TABLE_MAX_CHANNELS 8 // Maximum number of channels per band
#define VTX_TABLE_MAX_POWER_LEVELS 8 // Maximum number of power levels
#define VTX_TABLE_CHANNEL_NAME_LENGTH 1
#define VTX_TABLE_BAND_NAME_LENGTH 8
#define VTX_TABLE_POWER_LABEL_LENGTH 3
#else
#define VTX_TABLE_MAX_BANDS 5 // default freq table has 5 bands
#define VTX_TABLE_MAX_CHANNELS 8 // and eight channels
#define VTX_TABLE_MAX_POWER_LEVELS 5 //max of VTX_TRAMP_POWER_COUNT, VTX_SMARTAUDIO_POWER_COUNT and VTX_RTC6705_POWER_COUNT
#define VTX_TABLE_CHANNEL_NAME_LENGTH 1
#define VTX_TABLE_BAND_NAME_LENGTH 8
#define VTX_TABLE_POWER_LABEL_LENGTH 3
#endif
#define VTX_TABLE_MIN_USER_FREQ 5000
#define VTX_TABLE_MAX_USER_FREQ 5999
#define VTX_TABLE_DEFAULT_BAND 4
#define VTX_TABLE_DEFAULT_CHANNEL 1
#define VTX_TABLE_DEFAULT_FREQ 5740
#define VTX_TABLE_DEFAULT_PITMODE_FREQ 0
#ifdef USE_VTX_RTC6705
#define VTX_TABLE_DEFAULT_POWER VTX_RTC6705_DEFAULT_POWER_INDEX
#else
#define VTX_TABLE_DEFAULT_POWER 1 //lowest actual power mode
#endif
struct vtxTableConfig_s;
void vtxTableInit(void);
@ -40,13 +62,17 @@ void vtxTableConfigClearBand(struct vtxTableConfig_s *config, int band);
void vtxTableConfigClearPowerValues(struct vtxTableConfig_s *config, int start);
void vtxTableConfigClearPowerLabels(struct vtxTableConfig_s *config, int start);
void vtxTableConfigClearChannels(struct vtxTableConfig_s *config, int band, int channels);
#ifndef USE_VTX_TABLE
void vtxTableSetFactoryBands(bool isFactory);
#endif
extern int vtxTableBandCount;
extern int vtxTableChannelCount;
extern uint16_t vtxTableFrequency[VTX_TABLE_MAX_BANDS][VTX_TABLE_MAX_CHANNELS];
extern const char * vtxTableBandNames[VTX_TABLE_MAX_BANDS + 1];
extern const char *vtxTableBandNames[VTX_TABLE_MAX_BANDS + 1];
extern char vtxTableBandLetters[VTX_TABLE_MAX_BANDS + 1];
extern const char * vtxTableChannelNames[VTX_TABLE_MAX_CHANNELS + 1];
extern const char *vtxTableChannelNames[VTX_TABLE_MAX_CHANNELS + 1];
extern bool vtxTableIsFactoryBand[VTX_TABLE_MAX_BANDS];
extern int vtxTablePowerLevels;
extern uint16_t vtxTablePowerValues[VTX_TABLE_MAX_POWER_LEVELS];
extern const char * vtxTablePowerLabels[VTX_TABLE_MAX_POWER_LEVELS + 1];
extern const char *vtxTablePowerLabels[VTX_TABLE_MAX_POWER_LEVELS + 1];