mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-08-03 17:46:31 +03:00
Finish FM radio clean up
This commit is contained in:
64
app/fm.c
64
app/fm.c
@@ -226,28 +226,28 @@ Bail:
|
|||||||
static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// beeps cause bad audio clicks anf audio breaks :(
|
// beeps cause bad audio clicks anf audio breaks :(
|
||||||
// so don't use them
|
// so don't use them
|
||||||
|
|
||||||
|
|
||||||
g_key_input_count_down = key_input_timeout_500ms;
|
g_key_input_count_down = key_input_timeout_500ms;
|
||||||
|
|
||||||
if (key_held && !key_pressed)
|
if (key_held && !key_pressed)
|
||||||
return; // key just released after long press
|
return; // key just released after long press
|
||||||
|
|
||||||
if (!key_held && key_pressed)
|
if (!key_held && key_pressed)
|
||||||
{ // key just pressed
|
{ // key just pressed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_fkey_pressed && !key_held)
|
if (!g_fkey_pressed && !key_held)
|
||||||
{ // short key release
|
{ // short key release
|
||||||
uint8_t State;
|
uint8_t State;
|
||||||
|
|
||||||
if (g_ask_to_delete)
|
if (g_ask_to_delete)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_ask_to_save)
|
if (g_ask_to_save)
|
||||||
{
|
{
|
||||||
State = STATE_SAVE;
|
State = STATE_SAVE;
|
||||||
@@ -256,16 +256,17 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
{
|
{
|
||||||
if (g_fm_scan_state != FM_SCAN_OFF)
|
if (g_fm_scan_state != FM_SCAN_OFF)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
State = g_eeprom.fm_is_channel_mode ? STATE_USER_MODE : STATE_FREQ_MODE;
|
State = g_eeprom.fm_is_channel_mode ? STATE_USER_MODE : STATE_FREQ_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
INPUTBOX_Append(Key);
|
INPUTBOX_Append(Key);
|
||||||
|
|
||||||
g_request_display_screen = DISPLAY_FM;
|
g_request_display_screen = DISPLAY_FM;
|
||||||
|
|
||||||
if (State == STATE_FREQ_MODE)
|
if (State == STATE_FREQ_MODE)
|
||||||
{
|
{ // frequency mode
|
||||||
|
|
||||||
if (g_input_box_index == 1)
|
if (g_input_box_index == 1)
|
||||||
{
|
{
|
||||||
if (g_input_box[0] > 1)
|
if (g_input_box[0] > 1)
|
||||||
@@ -279,7 +280,7 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
if (g_input_box_index > 3)
|
if (g_input_box_index > 3)
|
||||||
{
|
{
|
||||||
uint32_t Frequency;
|
uint32_t Frequency;
|
||||||
|
|
||||||
g_input_box_index = 0;
|
g_input_box_index = 0;
|
||||||
|
|
||||||
NUMBER_Get(g_input_box, &Frequency);
|
NUMBER_Get(g_input_box, &Frequency);
|
||||||
@@ -291,13 +292,13 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
g_request_display_screen = DISPLAY_FM;
|
g_request_display_screen = DISPLAY_FM;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_eeprom.fm_selected_frequency = (uint16_t)Frequency;
|
g_eeprom.fm_selected_frequency = (uint16_t)Frequency;
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
g_another_voice_id = (voice_id_t)Key;
|
g_another_voice_id = (voice_id_t)Key;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
|
g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency;
|
||||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||||
g_request_save_fm = true;
|
g_request_save_fm = true;
|
||||||
@@ -307,12 +308,13 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (g_input_box_index == 2)
|
if (g_input_box_index == 2)
|
||||||
{
|
{ // channel mode
|
||||||
|
|
||||||
uint8_t Channel;
|
uint8_t Channel;
|
||||||
|
|
||||||
g_input_box_index = 0;
|
g_input_box_index = 0;
|
||||||
Channel = ((g_input_box[0] * 10) + g_input_box[1]) - 1;
|
Channel = ((g_input_box[0] * 10) + g_input_box[1]) - 1;
|
||||||
|
|
||||||
if (State == STATE_USER_MODE)
|
if (State == STATE_USER_MODE)
|
||||||
{
|
{
|
||||||
if (FM_CheckValidChannel(Channel))
|
if (FM_CheckValidChannel(Channel))
|
||||||
@@ -338,39 +340,39 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
|||||||
g_fm_channel_position = Channel;
|
g_fm_channel_position = Channel;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
g_another_voice_id = (voice_id_t)Key;
|
g_another_voice_id = (voice_id_t)Key;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// with f-key, or long press
|
// with f-key, or long press
|
||||||
|
|
||||||
g_fkey_pressed = false;
|
g_fkey_pressed = false;
|
||||||
g_update_status = true;
|
g_update_status = true;
|
||||||
g_request_display_screen = DISPLAY_FM;
|
g_request_display_screen = DISPLAY_FM;
|
||||||
|
|
||||||
switch (Key)
|
switch (Key)
|
||||||
{
|
{
|
||||||
case KEY_0:
|
case KEY_0:
|
||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_3:
|
case KEY_3:
|
||||||
g_eeprom.fm_is_channel_mode = !g_eeprom.fm_is_channel_mode;
|
g_eeprom.fm_is_channel_mode = !g_eeprom.fm_is_channel_mode;
|
||||||
|
|
||||||
if (!FM_ConfigureChannelState())
|
if (!FM_ConfigureChannelState())
|
||||||
{
|
{
|
||||||
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
|
||||||
g_request_save_fm = true;
|
g_request_save_fm = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -448,7 +450,7 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int channel = -1;
|
int channel = -1;
|
||||||
|
|
||||||
if (key_held || key_pressed)
|
if (key_held || key_pressed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -456,7 +458,7 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
|
|||||||
for (i = 0; i < ARRAY_SIZE(g_fm_channels) && channel < 0; i++)
|
for (i = 0; i < ARRAY_SIZE(g_fm_channels) && channel < 0; i++)
|
||||||
if (g_fm_channels[i] == g_eeprom.fm_frequency_playing)
|
if (g_fm_channels[i] == g_eeprom.fm_frequency_playing)
|
||||||
channel = i; // found it in the channel list
|
channel = i; // found it in the channel list
|
||||||
|
|
||||||
g_request_display_screen = DISPLAY_FM;
|
g_request_display_screen = DISPLAY_FM;
|
||||||
|
|
||||||
if (g_fm_scan_state == FM_SCAN_OFF)
|
if (g_fm_scan_state == FM_SCAN_OFF)
|
||||||
@@ -464,7 +466,7 @@ static void FM_Key_MENU(bool key_pressed, bool key_held)
|
|||||||
|
|
||||||
if (!g_eeprom.fm_is_channel_mode)
|
if (!g_eeprom.fm_is_channel_mode)
|
||||||
{ // frequency mode
|
{ // frequency mode
|
||||||
|
|
||||||
if (g_ask_to_save)
|
if (g_ask_to_save)
|
||||||
{
|
{
|
||||||
if (channel < 0)
|
if (channel < 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");
|
strcpy(String, "VFO");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sprintf(String, "CH %2u", g_eeprom.fm_selected_channel + 1);
|
sprintf(String, "CH %u", g_eeprom.fm_selected_channel + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (!g_fm_auto_scan)
|
if (!g_fm_auto_scan)
|
||||||
@@ -97,8 +97,8 @@ void UI_DisplayFM(void)
|
|||||||
memset(String, 0, sizeof(String));
|
memset(String, 0, sizeof(String));
|
||||||
|
|
||||||
if (g_ask_to_save || (g_eeprom.fm_is_channel_mode && g_input_box_index > 0))
|
if (g_ask_to_save || (g_eeprom.fm_is_channel_mode && g_input_box_index > 0))
|
||||||
{
|
{ // user is entering a channel number
|
||||||
UI_GenerateChannelString(String, g_fm_channel_position);
|
UI_GenerateChannelString(String, g_fm_channel_position, ' ');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (!g_ask_to_delete)
|
if (!g_ask_to_delete)
|
||||||
@@ -109,15 +109,16 @@ void UI_DisplayFM(void)
|
|||||||
UI_DisplayFrequency(String, 23, 4, false, true);
|
UI_DisplayFrequency(String, 23, 4, false, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // user is entering a frequency
|
||||||
UI_DisplayFrequency(g_input_box, 23, 4, true, false);
|
UI_DisplayFrequency(g_input_box, 23, 4, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(String, "CH %2u", g_eeprom.fm_selected_channel + 1);
|
sprintf(String, "CH %u", g_eeprom.fm_selected_channel + 1);
|
||||||
UI_PrintString(String, 0, 127, 4, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UI_PrintString(String, 0, 127, 4, 10);
|
||||||
|
|
||||||
// *************************************
|
// *************************************
|
||||||
|
|
||||||
|
26
ui/helper.c
26
ui/helper.c
@@ -26,25 +26,31 @@
|
|||||||
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
|
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
|
||||||
#endif
|
#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;
|
unsigned int i;
|
||||||
|
|
||||||
|
if (pString == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (g_input_box_index == 0)
|
if (g_input_box_index == 0)
|
||||||
{
|
{
|
||||||
sprintf(pString, "CH-%02u", Channel + 1);
|
sprintf(pString, "CH%c%02u", separating_char, Channel + 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pString[0] = 'C';
|
pString[0] = 'C';
|
||||||
pString[1] = 'H';
|
pString[1] = 'H';
|
||||||
pString[2] = '-';
|
pString[2] = separating_char;
|
||||||
for (i = 0; i < 2; i++)
|
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)
|
if (g_input_box_index > 0)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
@@ -53,13 +59,15 @@ void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bShowPrefix)
|
pString[0] = 0;
|
||||||
sprintf(pString, "CH-%03u", ChannelNumber + 1);
|
|
||||||
else
|
if (prefix)
|
||||||
|
strcpy(pString, prefix);
|
||||||
|
|
||||||
if (ChannelNumber == 0xFF)
|
if (ChannelNumber == 0xFF)
|
||||||
strcpy(pString, "NULL");
|
strcpy(pString, "NULL");
|
||||||
else
|
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)
|
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 <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void UI_GenerateChannelString(char *pString, const uint8_t Channel);
|
void UI_GenerateChannelString(char *pString, const uint8_t Channel, const char separating_char);
|
||||||
void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber);
|
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_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);
|
void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line);
|
||||||
#ifdef ENABLE_SMALL_BOLD
|
#ifdef ENABLE_SMALL_BOLD
|
||||||
|
@@ -760,7 +760,7 @@ void UI_DisplayMenu(void)
|
|||||||
char s[11];
|
char s[11];
|
||||||
const bool valid = RADIO_CheckValidChannel(g_sub_menu_selection, false, 0);
|
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
|
// channel name
|
||||||
BOARD_fetchChannelName(s, g_sub_menu_selection);
|
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 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;
|
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);
|
UI_PrintString(String, menu_item_x1, menu_item_x2, y, 8);
|
||||||
|
|
||||||
if (valid)
|
if (valid)
|
||||||
@@ -1065,7 +1065,7 @@ void UI_DisplayMenu(void)
|
|||||||
if (g_sub_menu_selection < 0)
|
if (g_sub_menu_selection < 0)
|
||||||
strcpy(String, "NULL");
|
strcpy(String, "NULL");
|
||||||
else
|
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 == 0xFF || !g_eeprom.scan_list_enabled[i])
|
||||||
if (g_sub_menu_selection < 0 || !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];
|
char s[11];
|
||||||
BOARD_fetchChannelName(s, g_scan_channel);
|
BOARD_fetchChannelName(s, g_scan_channel);
|
||||||
if (s[0] == 0)
|
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);
|
strcat(String, s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user