0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

lots more step sizes added, though the QS config software will only use the original 7 step sizes.

This commit is contained in:
OneOfEleven 2023-10-18 16:17:41 +01:00
parent 2e880a61e1
commit ce4528b4ee
12 changed files with 160 additions and 171 deletions

View File

@ -26,7 +26,6 @@ ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1 ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1 ENABLE_KEEP_MEM_NAME := 1
ENABLE_WIDE_RX := 1 ENABLE_WIDE_RX := 1
ENABLE_1250HZ_STEP := 1
ENABLE_TX_WHEN_AM := 0 ENABLE_TX_WHEN_AM := 0
ENABLE_F_CAL_MENU := 0 ENABLE_F_CAL_MENU := 0
ENABLE_TX_UNLOCK := 0 ENABLE_TX_UNLOCK := 0
@ -304,9 +303,6 @@ endif
ifeq ($(ENABLE_WIDE_RX),1) ifeq ($(ENABLE_WIDE_RX),1)
CFLAGS += -DENABLE_WIDE_RX CFLAGS += -DENABLE_WIDE_RX
endif endif
ifeq ($(ENABLE_1250HZ_STEP),1)
CFLAGS += -DENABLE_1250HZ_STEP
endif
ifeq ($(ENABLE_TX_WHEN_AM),1) ifeq ($(ENABLE_TX_WHEN_AM),1)
CFLAGS += -DENABLE_TX_WHEN_AM CFLAGS += -DENABLE_TX_WHEN_AM
endif endif

View File

@ -57,7 +57,6 @@ ENABLE_BIG_FREQ := 0 big font frequencies (like original
ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode) ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode)
ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)saving memory channel ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)saving memory channel
ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-end/PA not designed for full range) ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-end/PA not designed for full range)
ENABLE_1250HZ_STEP := 1 enable smaller 1.25kHz frequency steps
ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM
ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden frequency calibration menu ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden frequency calibration menu
ENABLE_TX_UNLOCK := 0 allow TX everywhere EXCEPT airband (108~136) .. TX harmonic content will cause interference to other services, do so entirely at your own risk ! ENABLE_TX_UNLOCK := 0 allow TX everywhere EXCEPT airband (108~136) .. TX harmonic content will cause interference to other services, do so entirely at your own risk !

View File

@ -340,8 +340,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
return; return;
} }
if (key_pressed) if (key_pressed && !key_held)
{ // key is pressed { // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
return; // don't use the key till it's released return; // don't use the key till it's released
} }
@ -519,8 +519,8 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
void MAIN_Key_EXIT(bool key_pressed, bool key_held) void MAIN_Key_EXIT(bool key_pressed, bool key_held)
{ {
if (!key_held && key_pressed) if (key_pressed && !key_held)
{ // exit key pressed { // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
@ -586,8 +586,9 @@ void MAIN_Key_EXIT(bool key_pressed, bool key_held)
void MAIN_Key_MENU(const bool key_pressed, const bool key_held) void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
{ {
if (key_pressed && !key_held) if (key_pressed && !key_held)
// menu key pressed { // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
}
if (key_held) if (key_held)
{ // menu key held down (long press) { // menu key held down (long press)
@ -685,10 +686,8 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
{ {
if (g_input_box_index > 0) if (g_input_box_index > 0)
{ // entering a channel, frequency or DTMF string { // entering a channel, frequency or DTMF string
if (!key_held && key_pressed) if (!key_held && key_pressed)
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
@ -763,6 +762,11 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo]; uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo];
if (key_pressed && !key_held)
{ // key just pressed
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
}
if (!key_pressed && if (!key_pressed &&
g_scan_state_dir == SCAN_STATE_DIR_OFF && g_scan_state_dir == SCAN_STATE_DIR_OFF &&
IS_NOT_NOAA_CHANNEL(Channel) && IS_NOT_NOAA_CHANNEL(Channel) &&
@ -831,7 +835,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
const frequency_band_t old_band = FREQUENCY_GetBand(g_tx_vfo->freq_config_rx.frequency); const frequency_band_t old_band = FREQUENCY_GetBand(g_tx_vfo->freq_config_rx.frequency);
const uint32_t frequency = APP_set_frequency_by_step(g_tx_vfo, Direction); const uint32_t frequency = APP_set_frequency_by_step(g_tx_vfo, Direction);
if (RX_freq_check(frequency) < 0) if (FREQUENCY_rx_freq_check(frequency) < 0)
{ // frequency not allowed { // frequency not allowed
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;

View File

@ -393,7 +393,7 @@ void MENU_AcceptSetting(void)
break; break;
case MENU_STEP: case MENU_STEP:
g_tx_vfo->step_setting = g_sub_menu_selection; g_tx_vfo->step_setting = step_freq_table_sorted[g_sub_menu_selection];
if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save)) if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save))
{ {
g_request_save_channel = 1; g_request_save_channel = 1;
@ -935,7 +935,7 @@ void MENU_ShowCurrentSetting(void)
break; break;
case MENU_STEP: case MENU_STEP:
g_sub_menu_selection = g_tx_vfo->step_setting; g_sub_menu_selection = FREQUENCY_get_step_index(STEP_FREQ_TABLE[g_tx_vfo->step_setting]);
break; break;
case MENU_TX_POWER: case MENU_TX_POWER:

View File

@ -180,95 +180,14 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
if (!g_search_single_frequency) if (!g_search_single_frequency)
{ {
#if 0 // determine what the current step size is for the detected frequency
// use the 7 VFO channels/bands to determine it
uint32_t Freq250 = FREQUENCY_FloorToStep(g_search_frequency, 250, 0); const unsigned int band = (unsigned int)FREQUENCY_GetBand(g_search_frequency);
uint32_t Freq625 = FREQUENCY_FloorToStep(g_search_frequency, 625, 0); g_search_step_setting = BOARD_fetchFrequencyStepSetting(band, g_eeprom.tx_vfo);
{ // round to nearest step size
int16_t Delta250 = (int16_t)g_search_frequency - (int16_t)Freq250; const uint16_t step_size = STEP_FREQ_TABLE[g_search_step_setting];
int16_t Delta625; g_search_frequency = ((g_search_frequency + (step_size / 2)) / step_size) * step_size;
}
if (125 < Delta250)
{
Delta250 = 250 - Delta250;
Freq250 += 250;
}
Delta625 = (int16_t)g_search_frequency - (int16_t)Freq625;
if (312 < Delta625)
{
Delta625 = 625 - Delta625;
Freq625 += 625;
}
if (Delta625 < Delta250)
{
g_search_step_setting = STEP_6_25kHz;
g_search_frequency = Freq625;
}
else
{
g_search_step_setting = STEP_2_5kHz;
g_search_frequency = Freq250;
}
#elif 0
#ifdef ENABLE_1250HZ_STEP
const step_setting_t small_step = STEP_1_25kHz;
const step_setting_t big_step = STEP_6_25kHz;
#else
const step_setting_t small_step = STEP_2_5kHz;
const step_setting_t big_step = STEP_6_25kHz;
#endif
const uint32_t small_step_freq = STEP_FREQ_TABLE[small_step];
const uint32_t big_step_freq = STEP_FREQ_TABLE[big_step];
uint32_t freq_small_step = FREQUENCY_FloorToStep(g_search_frequency, small_step_freq, 0);
uint32_t freq_big_step = FREQUENCY_FloorToStep(g_search_frequency, big_step_freq, 0);
int32_t delta_small_step = (int32_t)g_search_frequency - freq_small_step;
int32_t delta_big_step = (int32_t)g_search_frequency - freq_big_step;
if (delta_small_step > 125)
{
delta_small_step = STEP_FREQ_TABLE[small_step] - delta_small_step;
freq_big_step += small_step_freq;
}
delta_big_step = (int32_t)g_search_frequency - freq_big_step;
if (delta_big_step > 312)
{
delta_big_step = big_step_freq - delta_big_step;
freq_big_step += big_step_freq;
}
if (delta_small_step >= delta_big_step)
{
g_search_step_setting = small_step;
g_search_frequency = freq_small_step;
}
else
{
g_search_step_setting = big_step;
g_search_frequency = freq_big_step;
}
#else
// determine what the current step size is for the detected frequency
// use the 7 VFO channels/bands to determine it
const unsigned int band = (unsigned int)FREQUENCY_GetBand(g_search_frequency);
g_search_step_setting = BOARD_fetchFrequencyStepSetting(band, g_eeprom.tx_vfo);
{ // round to nearest step size
const uint16_t step_size = STEP_FREQ_TABLE[g_search_step_setting];
g_search_frequency = ((g_search_frequency + (step_size / 2)) / step_size) * step_size;
}
#endif
} }
if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST) if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST)

Binary file not shown.

Binary file not shown.

View File

@ -14,15 +14,16 @@
* limitations under the License. * limitations under the License.
*/ */
#include "driver/uart.h"
#include "frequencies.h" #include "frequencies.h"
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"
// the default AIRCOPY frequency to use // the default AIRCOPY frequency
uint32_t g_aircopy_freq = 41002500; uint32_t g_aircopy_freq = 41002500;
// FM broadcast band lower/upper limit // FM broadcast band lower/upper limit
const freq_band_table_t FM_RADIO_BAND = {760, 1080}; const freq_band_table_t FM_RADIO_BAND = {880, 1080};
// the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz // the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
const freq_band_table_t BX4819_BAND1 = { 1800000, 63000000}; const freq_band_table_t BX4819_BAND1 = { 1800000, 63000000};
@ -67,22 +68,63 @@ const freq_band_table_t FREQ_BAND_TABLE[7] =
}; };
#endif #endif
#ifdef ENABLE_1250HZ_STEP // the first 7 values MUST remain in those same positions (to remain compatible with the QS config windows software)
// includes 1.25kHz step const uint16_t STEP_FREQ_TABLE[21] = {
const uint16_t STEP_FREQ_TABLE[7] = {125, 250, 625, 1000, 1250, 2500, 833}; 250, 500, 625, 1000, 1250, 2500, 833,
// const uint16_t STEP_FREQ_TABLE[7] = {125, 250, 625, 1000, 1250, 2500, 833, 10, 50}; 1, 5, 10, 25, 50, 100, 125, 1500, 3000, 5000, 10000, 12500, 25000, 50000
#else };
// QS steps (*10 Hz) uint16_t step_freq_table_sorted[ARRAY_SIZE(STEP_FREQ_TABLE)];
const uint16_t STEP_FREQ_TABLE[7] = {250, 500, 625, 1000, 1250, 2500, 833};
// const uint16_t STEP_FREQ_TABLE[7] = {250, 500, 625, 1000, 1250, 2500, 833, 10, 50}; unsigned int FREQUENCY_get_step_index(const unsigned int step_size)
#endif { // return the index into 'STEP_FREQ_TABLE' for the supplied step size
unsigned int i;
for (i = 0; i < ARRAY_SIZE(step_freq_table_sorted); i++)
if (STEP_FREQ_TABLE[step_freq_table_sorted[i]] == step_size)
return i;
// not found, so default to 12.5kHz
return 11;
}
void FREQUENCY_init(void)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(step_freq_table_sorted); i++)
step_freq_table_sorted[i] = i;
// sort according to step size
for (i = 0; i < ARRAY_SIZE(step_freq_table_sorted) - 1; i++)
{
uint16_t step1 = STEP_FREQ_TABLE[step_freq_table_sorted[i]];
unsigned int k;
for (k = i + 1; k < ARRAY_SIZE(step_freq_table_sorted); k++)
{
const uint16_t step2 = STEP_FREQ_TABLE[step_freq_table_sorted[k]];
if (step2 < step1)
{ // swap
const uint16_t temp = step_freq_table_sorted[i];
step_freq_table_sorted[i] = step_freq_table_sorted[k];
step_freq_table_sorted[k] = temp;
step1 = STEP_FREQ_TABLE[step_freq_table_sorted[i]];
}
}
}
/*
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("step ..\r\n");
for (i = 0; i < ARRAY_SIZE(step_freq_table_sorted); i++)
UART_printf("%2u %2u %5u\r\n", i, step_freq_table_sorted[i], STEP_FREQ_TABLE[step_freq_table_sorted[i]]);
UART_SendText("\r\n");
#endif
*/
}
frequency_band_t FREQUENCY_GetBand(uint32_t Frequency) frequency_band_t FREQUENCY_GetBand(uint32_t Frequency)
{ {
int band; int band;
for (band = ARRAY_SIZE(FREQ_BAND_TABLE) - 1; band >= 0; band--) for (band = ARRAY_SIZE(FREQ_BAND_TABLE) - 1; band >= 0; band--)
if (Frequency >= FREQ_BAND_TABLE[band].lower) if (Frequency >= FREQ_BAND_TABLE[band].lower && Frequency < FREQ_BAND_TABLE[band].upper)
// if (Frequency < FREQ_BAND_TABLE[band].upper) // if (Frequency >= FREQ_BAND_TABLE[band].lower)
return (frequency_band_t)band; return (frequency_band_t)band;
return BAND1_50MHz; return BAND1_50MHz;
@ -132,7 +174,7 @@ uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower)
#endif #endif
} }
int TX_freq_check(const uint32_t Frequency) int FREQUENCY_tx_freq_check(const uint32_t Frequency)
{ // return '0' if TX frequency is allowed { // return '0' if TX frequency is allowed
// otherwise return '-1' // otherwise return '-1'
@ -222,7 +264,7 @@ int TX_freq_check(const uint32_t Frequency)
return -1; return -1;
} }
int RX_freq_check(const uint32_t Frequency) int FREQUENCY_rx_freq_check(const uint32_t Frequency)
{ // return '0' if RX frequency is allowed { // return '0' if RX frequency is allowed
// otherwise return '-1' // otherwise return '-1'

View File

@ -20,6 +20,7 @@
#include <stdint.h> #include <stdint.h>
#include "frequencies.h" #include "frequencies.h"
#include "misc.h"
enum frequency_band_e { enum frequency_band_e {
BAND_NONE = -1, BAND_NONE = -1,
@ -47,47 +48,52 @@ extern const freq_band_table_t BX4819_BAND2;
extern const freq_band_table_t FREQ_BAND_TABLE[7]; extern const freq_band_table_t FREQ_BAND_TABLE[7];
#ifdef ENABLE_1250HZ_STEP // 250, 500, 625, 1000, 1250, 2500, 833, 1, 5, 10, 25, 50, 100, 125, 1500, 3000, 5000, 10000, 12500, 25000, 50000
// includes 1.25kHz step enum step_setting_e {
enum step_setting_e { STEP_2_5kHz = 0,
STEP_1_25kHz = 0, STEP_5_0kHz,
STEP_2_5kHz, STEP_6_25kHz,
STEP_6_25kHz, STEP_10_0kHz,
STEP_10_0kHz, STEP_12_5kHz,
STEP_12_5kHz, STEP_25_0kHz,
STEP_25_0kHz, STEP_8_33kHz,
STEP_8_33kHz,
// STEP_100Hz, STEP_10Hz,
// STEP_500Hz STEP_50Hz,
}; STEP_100Hz,
#else STEP_250Hz,
// QS steps STEP_500Hz,
enum step_setting_e { STEP_1kHz,
STEP_2_5kHz = 0, STEP_1_25kHz,
STEP_5_0kHz, STEP_15kHz,
STEP_6_25kHz, STEP_30kHz,
STEP_10_0kHz, STEP_50kHz,
STEP_12_5kHz, STEP_100kHz,
STEP_25_0kHz, STEP_125kHz,
STEP_8_33kHz, STEP_250kHz,
// STEP_100Hz, STEP_500kHz
// STEP_500Hz };
};
#endif
typedef enum step_setting_e step_setting_t; typedef enum step_setting_e step_setting_t;
extern const uint16_t STEP_FREQ_TABLE[7]; extern const uint16_t STEP_FREQ_TABLE[21];
//extern const uint16_t STEP_FREQ_TABLE[9]; extern uint16_t step_freq_table_sorted[ARRAY_SIZE(STEP_FREQ_TABLE)];
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
extern const uint32_t NOAA_FREQUENCY_TABLE[10]; extern const uint32_t NOAA_FREQUENCY_TABLE[10];
#endif #endif
// ***********
unsigned int FREQUENCY_get_step_index(const unsigned int step_size);
void FREQUENCY_init(void);
frequency_band_t FREQUENCY_GetBand(uint32_t Frequency); 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); 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);
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower); uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower);
int TX_freq_check(const uint32_t Frequency); int FREQUENCY_tx_freq_check(const uint32_t Frequency);
int RX_freq_check(const uint32_t Frequency); int FREQUENCY_rx_freq_check(const uint32_t Frequency);
// ***********
#endif #endif

4
main.c
View File

@ -65,8 +65,8 @@ void Main(void)
| SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE; | SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE;
SYSTICK_Init(); SYSTICK_Init();
BOARD_Init();
UART_Init(); UART_Init();
BOARD_Init();
#if defined(ENABLE_UART) #if defined(ENABLE_UART)
UART_SendText(UART_Version_str); UART_SendText(UART_Version_str);
@ -80,6 +80,8 @@ void Main(void)
memset(g_dtmf_string, '-', sizeof(g_dtmf_string)); memset(g_dtmf_string, '-', sizeof(g_dtmf_string));
g_dtmf_string[sizeof(g_dtmf_string) - 1] = 0; g_dtmf_string[sizeof(g_dtmf_string) - 1] = 0;
FREQUENCY_init();
#if 0 #if 0
SETTINGS_restore_calibration(); SETTINGS_restore_calibration();
#endif #endif

View File

@ -1021,7 +1021,7 @@ void RADIO_PrepareTX(void)
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
} }
else else
if (TX_freq_check(g_current_vfo->p_tx->frequency) == 0) if (FREQUENCY_tx_freq_check(g_current_vfo->p_tx->frequency) == 0)
{ // TX frequency is allowed { // TX frequency is allowed
if (g_current_vfo->busy_channel_lock && g_current_function == FUNCTION_RECEIVE) if (g_current_vfo->busy_channel_lock && g_current_function == FUNCTION_RECEIVE)
State = VFO_STATE_BUSY; // busy RX'ing a station State = VFO_STATE_BUSY; // busy RX'ing a station

View File

@ -26,6 +26,7 @@
#include "driver/bk4819.h" #include "driver/bk4819.h"
#include "driver/eeprom.h" // EEPROM_ReadBuffer() #include "driver/eeprom.h" // EEPROM_ReadBuffer()
#include "driver/st7565.h" #include "driver/st7565.h"
#include "driver/uart.h"
#include "external/printf/printf.h" #include "external/printf/printf.h"
#include "frequencies.h" #include "frequencies.h"
#include "helper/battery.h" #include "helper/battery.h"
@ -410,8 +411,6 @@ void UI_SortMenu(const bool hide_hidden)
// this means the menu order is entirely determined by the enum list (found in id/menu.h) // this means the menu order is entirely determined by the enum list (found in id/menu.h)
// it now no longer depends on the order of entries in the above const list (they can be any order) // it now no longer depends on the order of entries in the above const list (they can be any order)
// unsigned int i;
unsigned int hidden_menu_count = g_hidden_menu_count; unsigned int hidden_menu_count = g_hidden_menu_count;
#ifndef ENABLE_F_CAL_MENU #ifndef ENABLE_F_CAL_MENU
@ -420,16 +419,22 @@ void UI_SortMenu(const bool hide_hidden)
g_menu_list_count = ARRAY_SIZE(g_menu_list); g_menu_list_count = ARRAY_SIZE(g_menu_list);
// linear index array
// for (i = 0; i < ARRAY_SIZE(g_menu_list_sorted); i++)
// g_menu_list_sorted[i] = i;
// sort non-hidden entries at the beginning // sort non-hidden entries at the beginning
sort_list(0, g_menu_list_count - hidden_menu_count); sort_list(0, g_menu_list_count - hidden_menu_count);
// sort the hidden entries at the end // sort the hidden entries at the end
sort_list(g_menu_list_count - hidden_menu_count, hidden_menu_count); sort_list(g_menu_list_count - hidden_menu_count, hidden_menu_count);
/*
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
{
unsigned int i;
UART_SendText("menu ..\r\n");
for (i = 0; i < ARRAY_SIZE(g_menu_list_sorted); i++)
UART_printf("%3u %3u %3u\r\n", i, g_menu_list_sorted[i], g_menu_list[g_menu_list_sorted[i]].menu_id);
UART_SendText("\r\n");
}
#endif
*/
if (hide_hidden) if (hide_hidden)
g_menu_list_count -= hidden_menu_count; // hide the hidden menu items g_menu_list_count -= hidden_menu_count; // hide the hidden menu items
} }
@ -544,8 +549,24 @@ void UI_DisplayMenu(void)
break; break;
case MENU_STEP: case MENU_STEP:
sprintf(String, "%d.%02ukHz", STEP_FREQ_TABLE[g_sub_menu_selection] / 100, STEP_FREQ_TABLE[g_sub_menu_selection] % 100); {
// const uint32_t step = (uint32_t)STEP_FREQ_TABLE[g_sub_menu_selection] * 10;
const uint32_t step = (uint32_t)STEP_FREQ_TABLE[step_freq_table_sorted[g_sub_menu_selection]] * 10;
if (step < 1000)
{ // Hz
sprintf(String, "%uHz", step);
}
else
{ // kHz
int i;
sprintf(String, "%u.%03u", step / 1000, step % 1000);
i = strlen(String) - 1;
while (i > 0 && String[i] == '0' && String[i - 1] != '.')
String[i--] = 0; // trim trailing zeros away
strcat(String, "kHz");
}
break; break;
}
case MENU_TX_POWER: case MENU_TX_POWER:
strcpy(String, g_sub_MENU_TX_POWER[g_sub_menu_selection]); strcpy(String, g_sub_MENU_TX_POWER[g_sub_menu_selection]);