mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Finish FM radio clean up
This commit is contained in:
parent
8c21a0e543
commit
6374160045
6
app/fm.c
6
app/fm.c
@ -265,7 +265,8 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_request_display_screen = DISPLAY_FM;
|
||||
|
||||
if (State == STATE_FREQ_MODE)
|
||||
{
|
||||
{ // frequency mode
|
||||
|
||||
if (g_input_box_index == 1)
|
||||
{
|
||||
if (g_input_box[0] > 1)
|
||||
@ -307,7 +308,8 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
}
|
||||
else
|
||||
if (g_input_box_index == 2)
|
||||
{
|
||||
{ // channel mode
|
||||
|
||||
uint8_t Channel;
|
||||
|
||||
g_input_box_index = 0;
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
13
ui/fmradio.c
13
ui/fmradio.c
@ -81,7 +81,7 @@ void UI_DisplayFM(void)
|
||||
strcpy(String, "VFO");
|
||||
}
|
||||
else
|
||||
sprintf(String, "CH %2u", g_eeprom.fm_selected_channel + 1);
|
||||
sprintf(String, "CH %u", g_eeprom.fm_selected_channel + 1);
|
||||
}
|
||||
else
|
||||
if (!g_fm_auto_scan)
|
||||
@ -97,8 +97,8 @@ void UI_DisplayFM(void)
|
||||
memset(String, 0, sizeof(String));
|
||||
|
||||
if (g_ask_to_save || (g_eeprom.fm_is_channel_mode && g_input_box_index > 0))
|
||||
{
|
||||
UI_GenerateChannelString(String, g_fm_channel_position);
|
||||
{ // user is entering a channel number
|
||||
UI_GenerateChannelString(String, g_fm_channel_position, ' ');
|
||||
}
|
||||
else
|
||||
if (!g_ask_to_delete)
|
||||
@ -109,16 +109,17 @@ void UI_DisplayFM(void)
|
||||
UI_DisplayFrequency(String, 23, 4, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
{ // user is entering a frequency
|
||||
UI_DisplayFrequency(g_input_box, 23, 4, true, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(String, "CH %2u", g_eeprom.fm_selected_channel + 1);
|
||||
UI_PrintString(String, 0, 127, 4, 10);
|
||||
sprintf(String, "CH %u", g_eeprom.fm_selected_channel + 1);
|
||||
}
|
||||
|
||||
UI_PrintString(String, 0, 127, 4, 10);
|
||||
|
||||
// *************************************
|
||||
|
||||
ST7565_BlitFullScreen();
|
||||
|
26
ui/helper.c
26
ui/helper.c
@ -26,25 +26,31 @@
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
|
||||
#endif
|
||||
|
||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel)
|
||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel, const char separating_char)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (pString == NULL)
|
||||
return;
|
||||
|
||||
if (g_input_box_index == 0)
|
||||
{
|
||||
sprintf(pString, "CH-%02u", Channel + 1);
|
||||
sprintf(pString, "CH%c%02u", separating_char, Channel + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
pString[0] = 'C';
|
||||
pString[1] = 'H';
|
||||
pString[2] = '-';
|
||||
pString[2] = separating_char;
|
||||
for (i = 0; i < 2; i++)
|
||||
pString[i + 3] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0';
|
||||
pString[i + 3] = (g_input_box[i] == 10) ? '_' : g_input_box[i] + '0';
|
||||
}
|
||||
|
||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber)
|
||||
void UI_GenerateChannelStringEx(char *pString, const char *prefix, const uint8_t ChannelNumber)
|
||||
{
|
||||
if (pString == NULL)
|
||||
return;
|
||||
|
||||
if (g_input_box_index > 0)
|
||||
{
|
||||
unsigned int i;
|
||||
@ -53,13 +59,15 @@ void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uin
|
||||
return;
|
||||
}
|
||||
|
||||
if (bShowPrefix)
|
||||
sprintf(pString, "CH-%03u", ChannelNumber + 1);
|
||||
else
|
||||
pString[0] = 0;
|
||||
|
||||
if (prefix)
|
||||
strcpy(pString, prefix);
|
||||
|
||||
if (ChannelNumber == 0xFF)
|
||||
strcpy(pString, "NULL");
|
||||
else
|
||||
sprintf(pString, "%03u", ChannelNumber + 1);
|
||||
sprintf(pString + strlen(prefix), "%03u", ChannelNumber + 1);
|
||||
}
|
||||
|
||||
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width)
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel);
|
||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber);
|
||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel, const char separating_char);
|
||||
void UI_GenerateChannelStringEx(char *pString, const char *prefix, const uint8_t ChannelNumber);
|
||||
void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width);
|
||||
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
|
@ -760,7 +760,7 @@ void UI_DisplayMenu(void)
|
||||
char s[11];
|
||||
const bool valid = RADIO_CheckValidChannel(g_sub_menu_selection, false, 0);
|
||||
|
||||
UI_GenerateChannelStringEx(String, valid, g_sub_menu_selection);
|
||||
UI_GenerateChannelStringEx(String, valid ? "CH-" : "", g_sub_menu_selection);
|
||||
|
||||
// channel name
|
||||
BOARD_fetchChannelName(s, g_sub_menu_selection);
|
||||
@ -781,7 +781,7 @@ void UI_DisplayMenu(void)
|
||||
const bool valid = RADIO_CheckValidChannel(g_sub_menu_selection, false, 0);
|
||||
const unsigned int y = (!g_is_in_sub_menu || g_edit_index < 0) ? 1 : 0;
|
||||
|
||||
UI_GenerateChannelStringEx(String, valid, g_sub_menu_selection);
|
||||
UI_GenerateChannelStringEx(String, valid ? "CH-" : "", g_sub_menu_selection);
|
||||
UI_PrintString(String, menu_item_x1, menu_item_x2, y, 8);
|
||||
|
||||
if (valid)
|
||||
@ -1065,7 +1065,7 @@ void UI_DisplayMenu(void)
|
||||
if (g_sub_menu_selection < 0)
|
||||
strcpy(String, "NULL");
|
||||
else
|
||||
UI_GenerateChannelStringEx(String, true, g_sub_menu_selection);
|
||||
UI_GenerateChannelStringEx(String, "CH-", g_sub_menu_selection);
|
||||
|
||||
// if (g_sub_menu_selection == 0xFF || !g_eeprom.scan_list_enabled[i])
|
||||
if (g_sub_menu_selection < 0 || !g_eeprom.scan_list_enabled[i])
|
||||
|
@ -168,7 +168,7 @@ void UI_DisplayScanner(void)
|
||||
char s[11];
|
||||
BOARD_fetchChannelName(s, g_scan_channel);
|
||||
if (s[0] == 0)
|
||||
UI_GenerateChannelStringEx(s, g_show_chan_prefix, g_scan_channel);
|
||||
UI_GenerateChannelStringEx(s, g_show_chan_prefix ? "CH-" : "", g_scan_channel);
|
||||
strcat(String, s);
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user