Refactor stepFruencyTable & drop ARRAY_SIZE for frequencyBandTable

This commit is contained in:
Juan Antonio
2023-12-08 23:15:54 +01:00
committed by Krzysiek Egzmont
parent 335c2ec9cd
commit 82ddbcd375
9 changed files with 62 additions and 38 deletions

View File

@@ -133,7 +133,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gInputBoxIndex = 0;
Frequency = StrToUL(INPUTBOX_GetAscii()) * 100;
for (i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
for (i = 0; i < BAND_N_ELEM; i++)
{
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
{

View File

@@ -152,7 +152,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep)
if (gTxVfo->Band == BAND5_350MHz && !gSetting_350EN) {
// skip if not enabled
gTxVfo->Band += 1;
} else if (gTxVfo->Band >= BAND_LAST_ELEMENT){
} else if (gTxVfo->Band >= BAND_N_ELEM){
// go arround if overflowed
gTxVfo->Band = BAND1_50MHz;
}
@@ -380,9 +380,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower;
}
else
if (Frequency > frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper)
if (Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper)
{
Frequency = frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper;
Frequency = frequencyBandTable[BAND_N_ELEM - 1].upper;
}
const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency);

View File

@@ -40,7 +40,6 @@
#endif
#include "ui/inputbox.h"
#include "ui/menu.h"
#include "ui/menu.h"
#include "ui/ui.h"
#ifndef ARRAY_SIZE
@@ -123,7 +122,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax)
case MENU_STEP:
*pMin = 0;
*pMax = ARRAY_SIZE(gStepFrequencyTable) - 1;
*pMax = STEP_N_ELEM - 1;
break;
case MENU_ABR:

View File

@@ -18,6 +18,7 @@
#include "am_fix.h"
#include "audio.h"
#include "driver/backlight.h"
#include "frequencies.h"
#include "ui/helper.h"
#include "ui/main.h"
@@ -28,7 +29,7 @@ struct FrequencyBandInfo {
};
#define F_MIN frequencyBandTable[0].lower
#define F_MAX frequencyBandTable[ARRAY_SIZE(frequencyBandTable) - 1].upper
#define F_MAX frequencyBandTable[BAND_N_ELEM - 1].upper
const uint16_t RSSI_MAX_VALUE = 65535;

View File

@@ -29,7 +29,6 @@
#include "../driver/systick.h"
#include "../external/printf/printf.h"
#include "../font.h"
#include "../frequencies.h"
#include "../helper/battery.h"
#include "../misc.h"
#include "../radio.h"