diff --git a/app/menu.c b/app/menu.c index 25666ff..3b2b55b 100644 --- a/app/menu.c +++ b/app/menu.c @@ -34,6 +34,10 @@ #include "ui/menu.h" #include "ui/ui.h" +#ifndef ARRAY_SIZE + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + #ifdef ENABLE_VOICE static const VOICE_ID_t MenuVoices[] = { @@ -133,14 +137,9 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax) break; case MENU_STEP: - if (gTxVfo->Band == BAND2_108MHz) - { - *pMin = 0; - *pMax = 6; - break; - } - - // Fallthrough + *pMin = 0; + *pMax = ARRAY_SIZE(StepFrequencyTable) - 1; + break; case MENU_ABR: case MENU_F_LOCK: diff --git a/firmware b/firmware index e1ee2fb..76a00e3 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 6fb1a9b..8d96241 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 9a1a2e7..13e4b0f 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/frequencies.c b/frequencies.c index cbba886..6277aff 100644 --- a/frequencies.c +++ b/frequencies.c @@ -79,24 +79,26 @@ const uint32_t UpperLimitFrequencyBandTable[7] = #endif #if 0 - const uint16_t StepFrequencyTable[6] = + const uint16_t StepFrequencyTable[7] = { 250, 500, 625, 1000, 1250, - 2500 + 2500, + 833 }; #else - const uint16_t StepFrequencyTable[6] = + const uint16_t StepFrequencyTable[7] = { 125, 250, 625, 1000, 1250, - 2500 + 2500, + 833 }; #endif diff --git a/frequencies.h b/frequencies.h index a4609ec..c7ee82b 100644 --- a/frequencies.h +++ b/frequencies.h @@ -45,7 +45,7 @@ extern const uint32_t UpperLimitFrequencyBandTable[7]; extern const uint32_t NoaaFrequencyTable[10]; #endif -extern const uint16_t StepFrequencyTable[6]; +extern const uint16_t StepFrequencyTable[7]; FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency); uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency); diff --git a/radio.c b/radio.c index 035cef0..0a1505f 100644 --- a/radio.c +++ b/radio.c @@ -34,6 +34,10 @@ #include "radio.h" #include "settings.h" +#ifndef ARRAY_SIZE + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + VFO_Info_t *gTxVfo; VFO_Info_t *gRxVfo; VFO_Info_t *gCurrentVfo; @@ -254,8 +258,8 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) gEeprom.VfoInfo[VFO].AM_CHANNEL_MODE = !!(Data[3] & 0x10); Tmp = Data[6]; - if (Tmp > STEP_8_33kHz) - Tmp = STEP_25_0kHz; + if (Tmp >= ARRAY_SIZE(StepFrequencyTable)) + Tmp = STEP_12_5kHz; gEeprom.VfoInfo[VFO].STEP_SETTING = Tmp; gEeprom.VfoInfo[VFO].StepFrequency = StepFrequencyTable[Tmp]; diff --git a/ui/menu.c b/ui/menu.c index af2accf..271fcff 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -22,6 +22,7 @@ #include "driver/eeprom.h" // EEPROM_ReadBuffer() #include "driver/st7565.h" #include "external/printf/printf.h" +#include "frequencies.h" #include "helper/battery.h" #include "misc.h" #include "settings.h" @@ -30,6 +31,10 @@ #include "ui/menu.h" #include "ui/ui.h" +#ifndef ARRAY_SIZE + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + const char MenuList[][7] = { "SQL", @@ -106,30 +111,6 @@ const char MenuList[][7] = "" // end of list }; -#if 0 - static const uint16_t gSubMenu_Step[] = - { - 250, - 500, - 625, - 1000, - 1250, - 2500, - 833 - }; -#else - static const uint16_t gSubMenu_Step[] = - { - 125, - 250, - 625, - 1000, - 1250, - 2500, - 833 - }; -#endif - static const char gSubMenu_TXP[3][5] = { "LOW", @@ -325,7 +306,7 @@ void UI_DisplayMenu(void) break; case MENU_STEP: - sprintf(String, "%u.%02uKHz", gSubMenu_Step[gSubMenuSelection] / 100, gSubMenu_Step[gSubMenuSelection] % 100); + sprintf(String, "%u.%02uKHz", StepFrequencyTable[gSubMenuSelection] / 100, StepFrequencyTable[gSubMenuSelection] % 100); break; case MENU_TXP: