diff --git a/app/fm.c b/app/fm.c index 0f974fe..c9e789d 100644 --- a/app/fm.c +++ b/app/fm.c @@ -226,28 +226,28 @@ Bail: static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held) { - + // beeps cause bad audio clicks anf audio breaks :( // so don't use them - - + + g_key_input_count_down = key_input_timeout_500ms; - + if (key_held && !key_pressed) return; // key just released after long press - + if (!key_held && key_pressed) { // key just pressed return; } - + if (!g_fkey_pressed && !key_held) { // short key release uint8_t State; - + if (g_ask_to_delete) return; - + if (g_ask_to_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) return; - + State = g_eeprom.fm_is_channel_mode ? STATE_USER_MODE : STATE_FREQ_MODE; } - + INPUTBOX_Append(Key); - + 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) @@ -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) { uint32_t Frequency; - + g_input_box_index = 0; 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; return; } - + g_eeprom.fm_selected_frequency = (uint16_t)Frequency; - + #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - + g_eeprom.fm_frequency_playing = g_eeprom.fm_selected_frequency; BK1080_SetFrequency(g_eeprom.fm_frequency_playing); 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 if (g_input_box_index == 2) - { + { // channel mode + uint8_t Channel; - + g_input_box_index = 0; Channel = ((g_input_box[0] * 10) + g_input_box[1]) - 1; - + if (State == STATE_USER_MODE) { 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; return; } - + return; } - + #ifdef ENABLE_VOICE g_another_voice_id = (voice_id_t)Key; #endif - + return; } // with f-key, or long press - + g_fkey_pressed = false; g_update_status = true; g_request_display_screen = DISPLAY_FM; - + switch (Key) { case KEY_0: ACTION_FM(); break; - + case KEY_3: g_eeprom.fm_is_channel_mode = !g_eeprom.fm_is_channel_mode; - + if (!FM_ConfigureChannelState()) { BK1080_SetFrequency(g_eeprom.fm_frequency_playing); g_request_save_fm = true; } break; - + default: break; } @@ -448,7 +450,7 @@ static void FM_Key_MENU(bool key_pressed, bool key_held) { unsigned int i; int channel = -1; - + if (key_held || key_pressed) 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++) if (g_fm_channels[i] == g_eeprom.fm_frequency_playing) channel = i; // found it in the channel list - + g_request_display_screen = DISPLAY_FM; 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) { // frequency mode - + if (g_ask_to_save) { if (channel < 0) diff --git a/firmware.bin b/firmware.bin index eceb37e..9ba467a 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 66cf73b..0f783b5 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/ui/fmradio.c b/ui/fmradio.c index fc1ed27..9ab933e 100644 --- a/ui/fmradio.c +++ b/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,15 +109,16 @@ 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); // ************************************* diff --git a/ui/helper.c b/ui/helper.c index ff7ea4b..1717baf 100644 --- a/ui/helper.c +++ b/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) diff --git a/ui/helper.h b/ui/helper.h index 6e9184e..6a4d115 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -20,8 +20,8 @@ #include #include -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 diff --git a/ui/menu.c b/ui/menu.c index 7011ddf..56bb3f0 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -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]) diff --git a/ui/scanner.c b/ui/scanner.c index 1cef95e..d6cc735 100644 --- a/ui/scanner.c +++ b/ui/scanner.c @@ -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;