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

channel name edit menu update

This commit is contained in:
OneOfEleven 2023-11-06 18:52:18 +00:00
parent 6f2fb9c7d6
commit 03fcb9570d
9 changed files with 45 additions and 34 deletions

View File

@ -742,7 +742,7 @@ static void APP_next_channel(void)
if (chan1 >= 0) if (chan1 >= 0)
{ {
if (RADIO_CheckValidChannel(chan1, false, 0)) if (RADIO_channel_valid(chan1, false, 0))
{ {
g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1;
g_scan_next_channel = chan1; g_scan_next_channel = chan1;
@ -755,7 +755,7 @@ static void APP_next_channel(void)
case SCAN_NEXT_CHAN_SCANLIST2: case SCAN_NEXT_CHAN_SCANLIST2:
if (chan2 >= 0) if (chan2 >= 0)
{ {
if (RADIO_CheckValidChannel(chan2, false, 0)) if (RADIO_channel_valid(chan2, false, 0))
{ {
g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST2; g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST2;
g_scan_next_channel = chan2; g_scan_next_channel = chan2;

View File

@ -164,7 +164,7 @@ void toggle_chan_scanlist(void)
{ // not found - find next free channel to save too { // not found - find next free channel to save too
//for (chan = g_eeprom.config.setting.indices.vfo[vfo].screen; chan <= USER_CHANNEL_LAST; chan++) //for (chan = g_eeprom.config.setting.indices.vfo[vfo].screen; chan <= USER_CHANNEL_LAST; chan++)
for (chan = 0; chan <= USER_CHANNEL_LAST; chan++) for (chan = 0; chan <= USER_CHANNEL_LAST; chan++)
if (!RADIO_CheckValidChannel(chan, false, vfo)) if (!RADIO_channel_valid(chan, false, vfo))
break; break;
} }
@ -406,7 +406,7 @@ void processFKeyFunction(const key_code_t Key)
case KEY_9: // CALL case KEY_9: // CALL
if (!RADIO_CheckValidChannel(g_eeprom.config.setting.call1, false, 0)) if (!RADIO_channel_valid(g_eeprom.config.setting.call1, false, 0))
{ {
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
@ -521,7 +521,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
g_input_box_index = 0; g_input_box_index = 0;
if (!RADIO_CheckValidChannel(chan, false, 0)) if (!RADIO_channel_valid(chan, false, 0))
{ {
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;

View File

@ -524,22 +524,25 @@ void MENU_AcceptSetting(void)
case MENU_MEM_NAME: case MENU_MEM_NAME:
{ {
const unsigned int chan = g_sub_menu_selection; const unsigned int chan = g_sub_menu_selection;
t_channel_name *chan_name = &g_eeprom.config.channel_name[chan]; t_channel_name *chan_name = &g_eeprom.config.channel_name[chan];
int i; int i;
// trailing trim // trailing trim
for (i = 9; i >= 0; i--) for (i = 9; i >= 0; i--)
{ {
if (g_edit[i] != ' ' && g_edit[i] != '_' && g_edit[i] != 0x00 && g_edit[i] != 0xff) if (g_edit[i] != ' ' && g_edit[i] != '_' && g_edit[i] != 0 && g_edit[i] != 0xff)
break; break;
g_edit[i] = ' '; g_edit[i] = ' ';
} }
// save the channel name // save the channel name
memset(chan_name, 0, sizeof(t_channel_name)); if (g_eeprom.config.channel_attributes[chan].band <= BAND7_470MHz)
memcpy(chan_name->name, g_edit, sizeof(chan_name->name)); {
SETTINGS_save_chan_name(chan); memset(chan_name, 0, sizeof(t_channel_name));
memcpy(chan_name->name, g_edit, sizeof(chan_name->name));
SETTINGS_save_chan_name(chan);
}
} }
g_flag_reconfigure_vfos = true; g_flag_reconfigure_vfos = true;
@ -1619,7 +1622,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
#if 1 #if 1
if (g_menu_cursor == MENU_MEM_DEL || g_menu_cursor == MENU_MEM_NAME) if (g_menu_cursor == MENU_MEM_DEL || g_menu_cursor == MENU_MEM_NAME)
if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0)) if (!RADIO_channel_valid(g_sub_menu_selection, false, 0))
return; // invalid channel return; // invalid channel
#endif #endif
@ -1629,7 +1632,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
// if (g_menu_cursor != MENU_DTMF_LIST) // if (g_menu_cursor != MENU_DTMF_LIST)
{ {
g_input_box_index = 0; g_input_box_index = 0;
g_edit_index = -1; g_edit_index = -1;
} }
return; return;
@ -1639,7 +1642,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
{ {
if (g_edit_index < 0) if (g_edit_index < 0)
{ // enter channel name edit mode { // enter channel name edit mode
if (!RADIO_CheckValidChannel(g_sub_menu_selection, false, 0)) if (!RADIO_channel_valid(g_sub_menu_selection, false, 0))
return; return;
SETTINGS_fetch_channel_name(g_edit, g_sub_menu_selection); SETTINGS_fetch_channel_name(g_edit, g_sub_menu_selection);
@ -1812,18 +1815,26 @@ static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
{ // change the character { // change the character
if (key_pressed && g_edit_index < 10 && Direction != 0) if (key_pressed && g_edit_index < 10 && Direction != 0)
{ {
const char unwanted[] = "$%&!\"':;?^`|{}"; #if 0
char c = g_edit[g_edit_index] + Direction; const char unwanted[] = "$%&!\"':;?^`|{}";
unsigned int i = 0; char c = g_edit[g_edit_index] + Direction;
while (i < sizeof(unwanted) && c >= 32 && c <= 126) unsigned int i = 0;
{ while (i < sizeof(unwanted) && c >= 32 && c <= 126)
if (c == unwanted[i++]) {
{ // choose next character if (c == unwanted[i++])
c += Direction; { // choose next character
i = 0; c += Direction;
i = 0;
}
} }
} g_edit[g_edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c;
g_edit[g_edit_index] = (c < 32) ? 126 : (c > 126) ? 32 : c; #else
// choose next character
char c = g_edit[g_edit_index] + Direction;
while (c < 32 || c > 126)
c += Direction;
g_edit[g_edit_index] = c;
#endif
g_request_display_screen = DISPLAY_MENU; g_request_display_screen = DISPLAY_MENU;
} }

View File

@ -91,7 +91,7 @@ static void SEARCH_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
#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_search_show_chan_prefix = RADIO_CheckValidChannel(Channel, false, 0); g_search_show_chan_prefix = RADIO_channel_valid(Channel, false, 0);
g_search_channel = (uint8_t)Channel; g_search_channel = (uint8_t)Channel;
return; return;
} }
@ -194,7 +194,7 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST) if (g_tx_vfo->channel_save <= USER_CHANNEL_LAST)
{ // save to channel { // save to channel
g_search_channel = g_tx_vfo->channel_save; g_search_channel = g_tx_vfo->channel_save;
g_search_show_chan_prefix = RADIO_CheckValidChannel(g_tx_vfo->channel_save, false, 0); g_search_show_chan_prefix = RADIO_channel_valid(g_tx_vfo->channel_save, false, 0);
g_search_edit_state = SEARCH_EDIT_STATE_SAVE_CHAN; g_search_edit_state = SEARCH_EDIT_STATE_SAVE_CHAN;
} }
else else
@ -336,7 +336,7 @@ static void SEARCH_Key_UP_DOWN(bool key_pressed, bool pKeyHeld, int8_t Direction
if (g_search_edit_state == SEARCH_EDIT_STATE_SAVE_CHAN) if (g_search_edit_state == SEARCH_EDIT_STATE_SAVE_CHAN)
{ {
g_search_channel = NUMBER_AddWithWraparound(g_search_channel, Direction, 0, USER_CHANNEL_LAST); g_search_channel = NUMBER_AddWithWraparound(g_search_channel, Direction, 0, USER_CHANNEL_LAST);
g_search_show_chan_prefix = RADIO_CheckValidChannel(g_search_channel, false, 0); g_search_show_chan_prefix = RADIO_channel_valid(g_search_channel, false, 0);
g_request_display_screen = DISPLAY_SEARCH; g_request_display_screen = DISPLAY_SEARCH;
} }
else else

Binary file not shown.

Binary file not shown.

View File

@ -54,7 +54,7 @@ dcs_code_type_t g_current_code_type;
uint8_t g_selected_code; uint8_t g_selected_code;
vfo_state_t g_vfo_state[2]; vfo_state_t g_vfo_state[2];
bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) bool RADIO_channel_valid(uint16_t Channel, bool bCheckScanList, uint8_t VFO)
{ // return true if the channel appears valid { // return true if the channel appears valid
unsigned int i; unsigned int i;
@ -112,7 +112,7 @@ uint8_t RADIO_FindNextChannel(uint8_t Channel, scan_state_dir_t Direction, bool
if (Channel > USER_CHANNEL_LAST) if (Channel > USER_CHANNEL_LAST)
Channel = USER_CHANNEL_FIRST; Channel = USER_CHANNEL_FIRST;
if (RADIO_CheckValidChannel(Channel, bCheckScanList, VFO)) if (RADIO_channel_valid(Channel, bCheckScanList, VFO))
return Channel; return Channel;
Channel += Direction; Channel += Direction;

View File

@ -35,7 +35,7 @@ extern uint8_t g_selected_code;
extern vfo_state_t g_vfo_state[2]; extern vfo_state_t g_vfo_state[2];
bool RADIO_CheckValidChannel(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum); bool RADIO_channel_valid(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum);
uint8_t RADIO_FindNextChannel(uint8_t ChNum, scan_state_dir_t Direction, bool bCheckScanList, uint8_t RadioNum); uint8_t RADIO_FindNextChannel(uint8_t ChNum, scan_state_dir_t Direction, bool bCheckScanList, uint8_t RadioNum);
void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t Frequency); void RADIO_InitInfo(vfo_info_t *p_vfo, const uint8_t ChannelSave, const uint32_t Frequency);
void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure); void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure);

View File

@ -844,7 +844,7 @@ void UI_DisplayMenu(void)
case MENU_MEM_DEL: case MENU_MEM_DEL:
{ {
char s[11]; char s[11];
const bool valid = RADIO_CheckValidChannel(g_sub_menu_selection, false, 0); const bool valid = RADIO_channel_valid(g_sub_menu_selection, false, 0);
UI_GenerateChannelStringEx(str, valid ? "CH-" : "", g_sub_menu_selection); UI_GenerateChannelStringEx(str, valid ? "CH-" : "", g_sub_menu_selection);
@ -869,7 +869,7 @@ void UI_DisplayMenu(void)
case MENU_MEM_NAME: case MENU_MEM_NAME:
{ {
const bool valid = RADIO_CheckValidChannel(g_sub_menu_selection, false, 0); const bool valid = RADIO_channel_valid(g_sub_menu_selection, false, 0);
const unsigned int y = (!g_in_sub_menu || g_edit_index < 0) ? 1 : 0; const unsigned int y = (!g_in_sub_menu || g_edit_index < 0) ? 1 : 0;
UI_GenerateChannelStringEx(str, valid ? "CH-" : "", g_sub_menu_selection); UI_GenerateChannelStringEx(str, valid ? "CH-" : "", g_sub_menu_selection);