mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-20 06:45:16 +03:00
Size of frequency table (stride) is now fixed constant
This commit is contained in:
parent
96fc6dc934
commit
9b06b570e1
4 changed files with 21 additions and 4 deletions
|
@ -153,6 +153,10 @@ const char *vtxCommonLookupChannelName(const vtxDevice_t *vtxDevice, int channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX FIXME Size of a band in the frequency table is now fixed at
|
||||||
|
// VTX_SETTINGS_MAX_CHANNEL (or VTX_TABLE_MAX_CHANNELS).
|
||||||
|
// Size constant should be consolidated soon or later.
|
||||||
|
|
||||||
//Converts frequency (in MHz) to band and channel values.
|
//Converts frequency (in MHz) to band and channel values.
|
||||||
bool vtxCommonLookupBandChan(const vtxDevice_t *vtxDevice, uint16_t freq, uint8_t *pBand, uint8_t *pChannel)
|
bool vtxCommonLookupBandChan(const vtxDevice_t *vtxDevice, uint16_t freq, uint8_t *pBand, uint8_t *pChannel)
|
||||||
{
|
{
|
||||||
|
@ -161,7 +165,7 @@ bool vtxCommonLookupBandChan(const vtxDevice_t *vtxDevice, uint16_t freq, uint8_
|
||||||
// get Raceband 7 instead of Fatshark 8.
|
// get Raceband 7 instead of Fatshark 8.
|
||||||
for (int band = vtxDevice->capability.bandCount - 1 ; band >= 0 ; band--) {
|
for (int band = vtxDevice->capability.bandCount - 1 ; band >= 0 ; band--) {
|
||||||
for (int channel = 0 ; channel < vtxDevice->capability.channelCount ; channel++) {
|
for (int channel = 0 ; channel < vtxDevice->capability.channelCount ; channel++) {
|
||||||
if (vtxDevice->frequencyTable[band * vtxDevice->capability.channelCount + channel] == freq) {
|
if (vtxDevice->frequencyTable[band * VTX_SETTINGS_MAX_CHANNEL + channel] == freq) {
|
||||||
*pBand = band + 1;
|
*pBand = band + 1;
|
||||||
*pChannel = channel + 1;
|
*pChannel = channel + 1;
|
||||||
return true;
|
return true;
|
||||||
|
@ -185,7 +189,7 @@ uint16_t vtxCommonLookupFrequency(const vtxDevice_t *vtxDevice, int band, int ch
|
||||||
if (vtxDevice) {
|
if (vtxDevice) {
|
||||||
if (band > 0 && band <= vtxDevice->capability.bandCount &&
|
if (band > 0 && band <= vtxDevice->capability.bandCount &&
|
||||||
channel > 0 && channel <= vtxDevice->capability.channelCount) {
|
channel > 0 && channel <= vtxDevice->capability.channelCount) {
|
||||||
return vtxDevice->frequencyTable[(band - 1) * vtxDevice->capability.channelCount + (channel - 1)];
|
return vtxDevice->frequencyTable[(band - 1) * VTX_SETTINGS_MAX_CHANNEL + (channel - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ void vtxTableInit(void)
|
||||||
{
|
{
|
||||||
const vtxTableConfig_t *config = vtxTableConfig();
|
const vtxTableConfig_t *config = vtxTableConfig();
|
||||||
|
|
||||||
|
vtxTableBandCount = config->bands;
|
||||||
|
vtxTableChannelCount = config->channels;
|
||||||
|
|
||||||
for (int band = 0; band < VTX_TABLE_MAX_BANDS; band++) {
|
for (int band = 0; band < VTX_TABLE_MAX_BANDS; band++) {
|
||||||
for (int channel = 0; channel < VTX_TABLE_MAX_CHANNELS; channel++) {
|
for (int channel = 0; channel < VTX_TABLE_MAX_CHANNELS; channel++) {
|
||||||
vtxTableFrequency[band][channel] = config->frequency[band][channel];
|
vtxTableFrequency[band][channel] = config->frequency[band][channel];
|
||||||
|
|
|
@ -40,3 +40,13 @@ void vtxTableConfigClearBand(struct vtxTableConfig_s *config, int band);
|
||||||
void vtxTableConfigClearPowerValues(struct vtxTableConfig_s *config, int start);
|
void vtxTableConfigClearPowerValues(struct vtxTableConfig_s *config, int start);
|
||||||
void vtxTableConfigClearPowerLabels(struct vtxTableConfig_s *config, int start);
|
void vtxTableConfigClearPowerLabels(struct vtxTableConfig_s *config, int start);
|
||||||
void vtxTableConfigClearChannels(struct vtxTableConfig_s *config, int band, int channels);
|
void vtxTableConfigClearChannels(struct vtxTableConfig_s *config, int band, int channels);
|
||||||
|
|
||||||
|
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 char vtxTableBandLetters[VTX_TABLE_MAX_BANDS + 1];
|
||||||
|
extern const char * vtxTableChannelNames[VTX_TABLE_MAX_CHANNELS + 1];
|
||||||
|
extern int vtxTablePowerLevels;
|
||||||
|
extern uint16_t vtxTablePowerValues[VTX_TABLE_MAX_POWER_LEVELS];
|
||||||
|
extern const char * vtxTablePowerLabels[VTX_TABLE_MAX_POWER_LEVELS + 1];
|
||||||
|
|
|
@ -140,8 +140,8 @@
|
||||||
#define PG_SERIAL_UART_CONFIG 543
|
#define PG_SERIAL_UART_CONFIG 543
|
||||||
#define PG_RPM_FILTER_CONFIG 544
|
#define PG_RPM_FILTER_CONFIG 544
|
||||||
#define PG_LED_STRIP_STATUS_MODE_CONFIG 545 // Used to hold the configuration for the LED_STRIP status mode (not built on targets with limited flash)
|
#define PG_LED_STRIP_STATUS_MODE_CONFIG 545 // Used to hold the configuration for the LED_STRIP status mode (not built on targets with limited flash)
|
||||||
#define PG_VTX_TABLE_CONFIG 545
|
#define PG_VTX_TABLE_CONFIG 546
|
||||||
#define PG_BETAFLIGHT_END 545
|
#define PG_BETAFLIGHT_END 546
|
||||||
|
|
||||||
|
|
||||||
// OSD configuration (subject to change)
|
// OSD configuration (subject to change)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue