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

Use memcpy() instead of memmove() when it's possible (two memmove call were kept).

Rename some variable named 'String' (to 'str') which is quite confusing.
This commit is contained in:
Daniel Caujolle-Bert 2023-10-24 11:40:35 +02:00
parent 024c4bb79d
commit 64f19b2d78
No known key found for this signature in database
GPG Key ID: 51AED7171EC00614
12 changed files with 317 additions and 317 deletions

View File

@ -122,7 +122,7 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
if (j == 3) if (j == 3)
{ {
memmove(pResult, Contact, 8); memcpy(pResult, Contact, 8);
pResult[8] = 0; pResult[8] = 0;
return true; return true;
} }
@ -354,8 +354,8 @@ void DTMF_HandleRequest(void)
memset(g_dtmf_callee, 0, sizeof(g_dtmf_callee)); memset(g_dtmf_callee, 0, sizeof(g_dtmf_callee));
memset(g_dtmf_caller, 0, sizeof(g_dtmf_caller)); memset(g_dtmf_caller, 0, sizeof(g_dtmf_caller));
memmove(g_dtmf_callee, g_dtmf_rx + Offset + 0, 3); memcpy(g_dtmf_callee, g_dtmf_rx + Offset + 0, 3);
memmove(g_dtmf_caller, g_dtmf_rx + Offset + 4, 3); memcpy(g_dtmf_caller, g_dtmf_rx + Offset + 4, 3);
DTMF_clear_RX(); DTMF_clear_RX();

View File

@ -785,7 +785,7 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save)) if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
{ // start entering a DTMF string { // start entering a DTMF string
memmove( g_dtmf_input_box, g_dtmf_string, memcpy( g_dtmf_input_box, g_dtmf_string,
(sizeof(g_dtmf_input_box) <= (sizeof(g_dtmf_string) - 1)) ? sizeof(g_dtmf_input_box) : sizeof(g_dtmf_string) - 1); (sizeof(g_dtmf_input_box) <= (sizeof(g_dtmf_string) - 1)) ? sizeof(g_dtmf_input_box) : sizeof(g_dtmf_string) - 1);
g_dtmf_input_box_index = 0; g_dtmf_input_box_index = 0;

View File

@ -535,7 +535,7 @@ void MENU_AcceptSetting(void)
// save the channel name // save the channel name
memset(g_tx_vfo->name, 0, sizeof(g_tx_vfo->name)); memset(g_tx_vfo->name, 0, sizeof(g_tx_vfo->name));
memmove(g_tx_vfo->name, g_edit, 10); memcpy(g_tx_vfo->name, g_edit, 10);
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3); SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3);
g_flag_reconfigure_vfos = true; g_flag_reconfigure_vfos = true;
return; return;
@ -742,7 +742,7 @@ void MENU_AcceptSetting(void)
GUI_SelectNextDisplay(DISPLAY_MAIN); GUI_SelectNextDisplay(DISPLAY_MAIN);
g_dtmf_input_mode = true; g_dtmf_input_mode = true;
g_dtmf_input_box_index = 3; g_dtmf_input_box_index = 3;
memmove(g_dtmf_input_box, g_dtmf_id, 4); memcpy(g_dtmf_input_box, g_dtmf_id, 4);
g_request_display_screen = DISPLAY_INVALID; g_request_display_screen = DISPLAY_INVALID;
} }
return; return;
@ -1624,7 +1624,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
g_edit_index = 0; // 'g_edit_index' is going to be used as the cursor position g_edit_index = 0; // 'g_edit_index' is going to be used as the cursor position
// make a copy so we can test for change when exiting the menu item // make a copy so we can test for change when exiting the menu item
memmove(g_edit_original, g_edit, sizeof(g_edit_original)); memcpy(g_edit_original, g_edit, sizeof(g_edit_original));
return; return;
} }

View File

@ -209,7 +209,7 @@ static void SendVersion(void)
memset(&reply, 0, sizeof(reply)); memset(&reply, 0, sizeof(reply));
reply.Header.ID = 0x0515; reply.Header.ID = 0x0515;
reply.Header.Size = sizeof(reply.Data); reply.Header.Size = sizeof(reply.Data);
memmove(reply.Data.Version, Version_str, slen); memcpy(reply.Data.Version, Version_str, slen);
reply.Data.has_custom_aes_key = g_has_custom_aes_key; reply.Data.has_custom_aes_key = g_has_custom_aes_key;
reply.Data.password_locked = g_password_locked; reply.Data.password_locked = g_password_locked;
reply.Data.Challenge[0] = g_challenge[0]; reply.Data.Challenge[0] = g_challenge[0];
@ -420,13 +420,13 @@ static void cmd_052D(const uint8_t *pBuffer)
if (!locked) if (!locked)
{ {
memmove((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings memcpy((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings
locked = IsBadChallenge(g_custom_aes_key, g_challenge, response); locked = IsBadChallenge(g_custom_aes_key, g_challenge, response);
} }
if (!locked) if (!locked)
{ {
memmove((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings memcpy((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings
locked = IsBadChallenge(g_default_aes_key, g_challenge, response); locked = IsBadChallenge(g_default_aes_key, g_challenge, response);
if (locked) if (locked)
try_count++; try_count++;
@ -546,11 +546,11 @@ bool UART_IsCommandAvailable(void)
if (TailIndex < Index) if (TailIndex < Index)
{ {
const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index; const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index;
memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize); memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize);
memmove(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex); memcpy(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex);
} }
else else
memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index); memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index);
TailIndex = DMA_INDEX(TailIndex, 2); TailIndex = DMA_INDEX(TailIndex, 2);
if (TailIndex < write_index) if (TailIndex < write_index)

12
board.c
View File

@ -605,7 +605,7 @@ void BOARD_EEPROM_load(void)
// 0E98..0E9F // 0E98..0E9F
EEPROM_ReadBuffer(0x0E98, Data, 8); EEPROM_ReadBuffer(0x0E98, Data, 8);
memmove(&g_eeprom.power_on_password, Data, 4); memcpy(&g_eeprom.power_on_password, Data, sizeof(g_eeprom.power_on_password));
// 0EA0..0EA7 // 0EA0..0EA7
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
@ -667,7 +667,7 @@ void BOARD_EEPROM_load(void)
// 0EE0..0EE7 // 0EE0..0EE7
EEPROM_ReadBuffer(0x0EE0, Data, 8); EEPROM_ReadBuffer(0x0EE0, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(g_eeprom.ani_dtmf_id, Data, 8); memcpy(g_eeprom.ani_dtmf_id, Data, sizeof(g_eeprom.power_on_password));
else else
{ {
memset(g_eeprom.ani_dtmf_id, 0, sizeof(g_eeprom.ani_dtmf_id)); memset(g_eeprom.ani_dtmf_id, 0, sizeof(g_eeprom.ani_dtmf_id));
@ -677,7 +677,7 @@ void BOARD_EEPROM_load(void)
// 0EE8..0EEF // 0EE8..0EEF
EEPROM_ReadBuffer(0x0EE8, Data, 8); EEPROM_ReadBuffer(0x0EE8, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(g_eeprom.kill_code, Data, 8); memcpy(g_eeprom.kill_code, Data, sizeof(g_eeprom.kill_code));
else else
{ {
memset(g_eeprom.kill_code, 0, sizeof(g_eeprom.kill_code)); memset(g_eeprom.kill_code, 0, sizeof(g_eeprom.kill_code));
@ -687,7 +687,7 @@ void BOARD_EEPROM_load(void)
// 0EF0..0EF7 // 0EF0..0EF7
EEPROM_ReadBuffer(0x0EF0, Data, 8); EEPROM_ReadBuffer(0x0EF0, Data, 8);
if (DTMF_ValidateCodes((char *)Data, 8)) if (DTMF_ValidateCodes((char *)Data, 8))
memmove(g_eeprom.revive_code, Data, 8); memcpy(g_eeprom.revive_code, Data, sizeof(g_eeprom.revive_code));
else else
{ {
memset(g_eeprom.revive_code, 0, sizeof(g_eeprom.revive_code)); memset(g_eeprom.revive_code, 0, sizeof(g_eeprom.revive_code));
@ -697,7 +697,7 @@ void BOARD_EEPROM_load(void)
// 0EF8..0F07 // 0EF8..0F07
EEPROM_ReadBuffer(0x0EF8, Data, 16); EEPROM_ReadBuffer(0x0EF8, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(g_eeprom.dtmf_key_up_code, Data, 16); memcpy(g_eeprom.dtmf_key_up_code, Data, sizeof(g_eeprom.dtmf_key_up_code));
else else
{ {
memset(g_eeprom.dtmf_key_up_code, 0, sizeof(g_eeprom.dtmf_key_up_code)); memset(g_eeprom.dtmf_key_up_code, 0, sizeof(g_eeprom.dtmf_key_up_code));
@ -707,7 +707,7 @@ void BOARD_EEPROM_load(void)
// 0F08..0F17 // 0F08..0F17
EEPROM_ReadBuffer(0x0F08, Data, 16); EEPROM_ReadBuffer(0x0F08, Data, 16);
if (DTMF_ValidateCodes((char *)Data, 16)) if (DTMF_ValidateCodes((char *)Data, 16))
memmove(g_eeprom.dtmf_key_down_code, Data, 16); memcpy(g_eeprom.dtmf_key_down_code, Data, sizeof(g_eeprom.dtmf_key_down_code));
else else
{ {
memset(g_eeprom.dtmf_key_down_code, 0, sizeof(g_eeprom.dtmf_key_down_code)); memset(g_eeprom.dtmf_key_down_code, 0, sizeof(g_eeprom.dtmf_key_down_code));

View File

@ -421,7 +421,7 @@ void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, c
EEPROM_WriteBuffer8(eeprom_addr + 8, name + 8); EEPROM_WriteBuffer8(eeprom_addr + 8, name + 8);
#else #else
if (p_vfo != NULL) if (p_vfo != NULL)
memmove(name, p_vfo->name, 10); memcpy(name, p_vfo->name, 10);
if (mode >= 3 || p_vfo == NULL) if (mode >= 3 || p_vfo == NULL)
{ // save the channel name { // save the channel name
EEPROM_WriteBuffer8(eeprom_addr + 0, name + 0); EEPROM_WriteBuffer8(eeprom_addr + 0, name + 0);
@ -468,7 +468,7 @@ void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_
if (p_vfo != NULL) if (p_vfo != NULL)
{ {
memset(name, 0, sizeof(name)); memset(name, 0, sizeof(name));
memmove(name, p_vfo->name, 10); memcpy(name, p_vfo->name, 10);
} }
else else
{ {

View File

@ -30,7 +30,7 @@ void UI_DrawBattery(uint8_t *bitmap, const unsigned int level, const unsigned in
} }
else else
{ {
memmove(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL)); memcpy(bitmap, BITMAP_BATTERY_LEVEL, sizeof(BITMAP_BATTERY_LEVEL));
if (level > 1) if (level > 1)
{ {
unsigned int i; unsigned int i;

View File

@ -84,8 +84,8 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
{ {
const unsigned int index = pString[i] - ' '; const unsigned int index = pString[i] - ' ';
const unsigned int ofs = (unsigned int)Start + (i * Width); const unsigned int ofs = (unsigned int)Start + (i * Width);
memmove(g_frame_buffer[Line + 0] + ofs, &g_font_big[index][0], 8); memcpy(g_frame_buffer[Line + 0] + ofs, &g_font_big[index][0], 8);
memmove(g_frame_buffer[Line + 1] + ofs, &g_font_big[index][8], 7); memcpy(g_frame_buffer[Line + 1] + ofs, &g_font_big[index][8], 7);
} }
} }
} }
@ -113,7 +113,7 @@ void UI_print_string(
{ {
const int c = (int)str[i] - ' '; const int c = (int)str[i] - ' ';
if (c >= 0 && c < (int)font_size) if (c >= 0 && c < (int)font_size)
memmove(f_buf + (char_pitch * i), font + (char_width * c), char_width); memcpy(f_buf + (char_pitch * i), font + (char_width * c), char_width);
} }
} }
@ -194,7 +194,7 @@ void UI_PrintStringSmallBuffer(const char *pString, uint8_t *buffer)
{ {
const int c = (int)pString[i] - ' '; const int c = (int)pString[i] - ' ';
if (c >= 0 && c < (int)ARRAY_SIZE(g_font_small)) if (c >= 0 && c < (int)ARRAY_SIZE(g_font_small))
memmove(buffer + (i * char_spacing) + 1, &g_font_small[c], char_width); memcpy(buffer + (i * char_spacing) + 1, &g_font_small[c], char_width);
} }
} }
@ -213,8 +213,8 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla
if (bDisplayLeadingZero || bCanDisplay || Digit > 0) if (bDisplayLeadingZero || bCanDisplay || Digit > 0)
{ {
bCanDisplay = true; bCanDisplay = true;
memmove(pFb0, g_font_big_digits[Digit], char_width); memcpy(pFb0, g_font_big_digits[Digit], char_width);
memmove(pFb1, g_font_big_digits[Digit] + char_width, char_width); memcpy(pFb1, g_font_big_digits[Digit] + char_width, char_width);
} }
else else
if (flag) if (flag)
@ -235,8 +235,8 @@ void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDispla
while (i < 6) while (i < 6)
{ {
const unsigned int Digit = pDigits[i++]; const unsigned int Digit = pDigits[i++];
memmove(pFb0, g_font_big_digits[Digit], char_width); memcpy(pFb0, g_font_big_digits[Digit], char_width);
memmove(pFb1, g_font_big_digits[Digit] + char_width, char_width); memcpy(pFb1, g_font_big_digits[Digit] + char_width, char_width);
pFb0 += char_width; pFb0 += char_width;
pFb1 += char_width; pFb1 += char_width;
} }
@ -257,10 +257,10 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD
if (bDisplayLeadingZero || bCanDisplay || c > 0) if (bDisplayLeadingZero || bCanDisplay || c > 0)
{ {
#if 0 #if 0
memmove(pFb + 1, g_font_small_digits[c], char_width); memcpy(pFb + 1, g_font_small_digits[c], char_width);
#else #else
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32; const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
memmove(pFb + 1, g_font_small[index], char_width); memcpy(pFb + 1, g_font_small[index], char_width);
#endif #endif
pFb += spacing; pFb += spacing;
bCanDisplay = true; bCanDisplay = true;
@ -279,10 +279,10 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD
{ {
const unsigned int c = pDigits[i++]; const unsigned int c = pDigits[i++];
#if 0 #if 0
memmove(pFb + 1, g_font_small_digits[c], char_width); memcpy(pFb + 1, g_font_small_digits[c], char_width);
#else #else
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32; const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
memmove(pFb + 1, g_font_small[index], char_width); memcpy(pFb + 1, g_font_small[index], char_width);
#endif #endif
pFb += spacing; pFb += spacing;
} }
@ -303,10 +303,10 @@ void UI_Displaysmall_digits(const uint8_t size, const char *str, const uint8_t x
if (display && c < 11) if (display && c < 11)
{ {
#if 0 #if 0
memmove(g_frame_buffer[y] + xx, g_font_small_digits[c], char_width); memcpy(g_frame_buffer[y] + xx, g_font_small_digits[c], char_width);
#else #else
const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32; const unsigned int index = (c < 10) ? '0' - 32 + c : '-' - 32;
memmove(g_frame_buffer[y] + xx + 1, g_font_small[index], char_width); memcpy(g_frame_buffer[y] + xx + 1, g_font_small[index], char_width);
#endif #endif
xx += spacing; xx += spacing;
} }

168
ui/main.c
View File

@ -140,14 +140,14 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
switch (level) switch (level)
{ {
default: default:
case 7: memmove(p + 20, BITMAP_ANTENNA_LEVEL6, sizeof(BITMAP_ANTENNA_LEVEL6)); case 7: memcpy(p + 20, BITMAP_ANTENNA_LEVEL6, sizeof(BITMAP_ANTENNA_LEVEL6));
case 6: memmove(p + 17, BITMAP_ANTENNA_LEVEL5, sizeof(BITMAP_ANTENNA_LEVEL5)); case 6: memcpy(p + 17, BITMAP_ANTENNA_LEVEL5, sizeof(BITMAP_ANTENNA_LEVEL5));
case 5: memmove(p + 14, BITMAP_ANTENNA_LEVEL4, sizeof(BITMAP_ANTENNA_LEVEL4)); case 5: memcpy(p + 14, BITMAP_ANTENNA_LEVEL4, sizeof(BITMAP_ANTENNA_LEVEL4));
case 4: memmove(p + 11, BITMAP_ANTENNA_LEVEL3, sizeof(BITMAP_ANTENNA_LEVEL3)); case 4: memcpy(p + 11, BITMAP_ANTENNA_LEVEL3, sizeof(BITMAP_ANTENNA_LEVEL3));
case 3: memmove(p + 8, BITMAP_ANTENNA_LEVEL2, sizeof(BITMAP_ANTENNA_LEVEL2)); case 3: memcpy(p + 8, BITMAP_ANTENNA_LEVEL2, sizeof(BITMAP_ANTENNA_LEVEL2));
case 2: memmove(p + 5, BITMAP_ANTENNA_LEVEL1, sizeof(BITMAP_ANTENNA_LEVEL1)); case 2: memcpy(p + 5, BITMAP_ANTENNA_LEVEL1, sizeof(BITMAP_ANTENNA_LEVEL1));
case 1: memmove(p + 0, BITMAP_ANTENNA, sizeof(BITMAP_ANTENNA)); break; case 1: memcpy(p + 0, BITMAP_ANTENNA, sizeof(BITMAP_ANTENNA)); break;
case 0: memset( p + 0, 0, sizeof(BITMAP_ANTENNA)); break; case 0: memset(p + 0, 0, sizeof(BITMAP_ANTENNA)); break;
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
@ -405,7 +405,7 @@ void UI_DisplayMain(void)
#endif #endif
const unsigned int line0 = 0; // text screen line const unsigned int line0 = 0; // text screen line
const unsigned int line1 = 4; const unsigned int line1 = 4;
char String[22]; char str[22];
unsigned int vfo_num; unsigned int vfo_num;
center_line = CENTER_LINE_NONE; center_line = CENTER_LINE_NONE;
@ -474,29 +474,29 @@ void UI_DisplayMain(void)
memset(contact, 0, sizeof(contact)); memset(contact, 0, sizeof(contact));
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT)
{ {
strcpy(String, (g_dtmf_state == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT RESP" : "CALL OUT"); strcpy(str, (g_dtmf_state == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT RESP" : "CALL OUT");
} }
else else
if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED || g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY) if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED || g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY)
{ {
const bool found = DTMF_FindContact(g_dtmf_caller, contact); const bool found = DTMF_FindContact(g_dtmf_caller, contact);
contact[8] = 0; contact[8] = 0;
sprintf(String, "FROM %s", found ? contact : g_dtmf_caller); sprintf(str, "FROM %s", found ? contact : g_dtmf_caller);
} }
else else
if (g_dtmf_is_tx) if (g_dtmf_is_tx)
{ {
strcpy(String, (g_dtmf_state == DTMF_STATE_TX_SUCC) ? "DTMF TX SUCC" : "DTMF TX"); strcpy(str, (g_dtmf_state == DTMF_STATE_TX_SUCC) ? "DTMF TX SUCC" : "DTMF TX");
} }
} }
else else
{ {
sprintf(String, ">%s", g_dtmf_input_box); sprintf(str, ">%s", g_dtmf_input_box);
} }
String[16] = 0; str[16] = 0;
UI_PrintString(String, 2, 0, 0 + (vfo_num * 3), 8); UI_PrintString(str, 2, 0, 0 + (vfo_num * 3), 8);
memset(String, 0, sizeof(String)); memset(str, 0, sizeof(str));
if (!g_dtmf_input_mode) if (!g_dtmf_input_mode)
{ {
memset(contact, 0, sizeof(contact)); memset(contact, 0, sizeof(contact));
@ -504,23 +504,23 @@ void UI_DisplayMain(void)
{ {
const bool found = DTMF_FindContact(g_dtmf_string, contact); const bool found = DTMF_FindContact(g_dtmf_string, contact);
contact[15] = 0; contact[15] = 0;
sprintf(String, ">%s", found ? contact : g_dtmf_string); sprintf(str, ">%s", found ? contact : g_dtmf_string);
} }
else else
if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED || g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY) if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED || g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY)
{ {
const bool found = DTMF_FindContact(g_dtmf_callee, contact); const bool found = DTMF_FindContact(g_dtmf_callee, contact);
contact[15] = 0; contact[15] = 0;
sprintf(String, ">%s", found ? contact : g_dtmf_callee); sprintf(str, ">%s", found ? contact : g_dtmf_callee);
} }
else else
if (g_dtmf_is_tx) if (g_dtmf_is_tx)
{ {
sprintf(String, ">%s", g_dtmf_string); sprintf(str, ">%s", g_dtmf_string);
} }
} }
String[16] = 0; str[16] = 0;
UI_PrintString(String, 2, 0, 2 + (vfo_num * 3), 8); UI_PrintString(str, 2, 0, 2 + (vfo_num * 3), 8);
center_line = CENTER_LINE_IN_USE; center_line = CENTER_LINE_IN_USE;
continue; continue;
@ -528,19 +528,19 @@ void UI_DisplayMain(void)
// highlight the selected/used VFO with a marker // highlight the selected/used VFO with a marker
if (!single_vfo && same_vfo) if (!single_vfo && same_vfo)
memmove(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT)); memcpy(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT));
else else
if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF) if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF)
memmove(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT)); memcpy(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT));
} }
else else
if (!single_vfo) if (!single_vfo)
{ // highlight the selected/used VFO with a marker { // highlight the selected/used VFO with a marker
if (same_vfo) if (same_vfo)
memmove(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT)); memcpy(p_line0 + 0, BITMAP_VFO_DEFAULT, sizeof(BITMAP_VFO_DEFAULT));
else else
//if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF) //if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF)
memmove(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT)); memcpy(p_line0 + 0, BITMAP_VFO_NOT_DEFAULT, sizeof(BITMAP_VFO_NOT_DEFAULT));
} }
if (g_current_function == FUNCTION_TRANSMIT) if (g_current_function == FUNCTION_TRANSMIT)
@ -585,11 +585,11 @@ void UI_DisplayMain(void)
const unsigned int x = 2; const unsigned int x = 2;
const bool inputting = (g_input_box_index == 0 || g_eeprom.tx_vfo != vfo_num) ? false : true; const bool inputting = (g_input_box_index == 0 || g_eeprom.tx_vfo != vfo_num) ? false : true;
if (!inputting) if (!inputting)
NUMBER_ToDigits(g_eeprom.screen_channel[vfo_num] + 1, String); // show the memory channel number NUMBER_ToDigits(g_eeprom.screen_channel[vfo_num] + 1, str); // show the memory channel number
else else
memmove(String + 5, g_input_box, 3); // show the input text memcpy(str + 5, g_input_box, 3); // show the input text
UI_PrintStringSmall("M", x, 0, line + 1); UI_PrintStringSmall("M", x, 0, line + 1);
UI_Displaysmall_digits(3, String + 5, x + 7, line + 1, inputting); UI_Displaysmall_digits(3, str + 5, x + 7, line + 1, inputting);
} }
else else
if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num])) if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
@ -597,21 +597,21 @@ void UI_DisplayMain(void)
// show the frequency band number // show the frequency band number
const unsigned int x = 2; // was 14 const unsigned int x = 2; // was 14
// sprintf(String, "FB%u", 1 + g_eeprom.screen_channel[vfo_num] - FREQ_CHANNEL_FIRST); // sprintf(String, "FB%u", 1 + g_eeprom.screen_channel[vfo_num] - FREQ_CHANNEL_FIRST);
sprintf(String, "VFO%u", 1 + g_eeprom.screen_channel[vfo_num] - FREQ_CHANNEL_FIRST); sprintf(str, "VFO%u", 1 + g_eeprom.screen_channel[vfo_num] - FREQ_CHANNEL_FIRST);
UI_PrintStringSmall(String, x, 0, line + 1); UI_PrintStringSmall(str, x, 0, line + 1);
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
{ {
if (g_input_box_index == 0 || g_eeprom.tx_vfo != vfo_num) if (g_input_box_index == 0 || g_eeprom.tx_vfo != vfo_num)
{ // channel number { // channel number
sprintf(String, "N%u", 1 + g_eeprom.screen_channel[vfo_num] - NOAA_CHANNEL_FIRST); sprintf(str, "N%u", 1 + g_eeprom.screen_channel[vfo_num] - NOAA_CHANNEL_FIRST);
} }
else else
{ // user entering channel number { // user entering channel number
sprintf(String, "N%u%u", '0' + g_input_box[0], '0' + g_input_box[1]); sprintf(str, "N%u%u", '0' + g_input_box[0], '0' + g_input_box[1]);
} }
UI_PrintStringSmall(String, 7, 0, line + 1); UI_PrintStringSmall(str, 7, 0, line + 1);
} }
#endif #endif
@ -663,58 +663,58 @@ void UI_DisplayMain(void)
case MDF_FREQUENCY: // just channel frequency case MDF_FREQUENCY: // just channel frequency
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency, String); NUMBER_ToDigits(frequency, str);
// show the main large frequency digits // show the main large frequency digits
UI_DisplayFrequency(String, x, line, false, false); UI_DisplayFrequency(str, x, line, false, false);
// show the remaining 2 small frequency digits // show the remaining 2 small frequency digits
UI_Displaysmall_digits(2, String + 6, x + 81, line + 1, true); UI_Displaysmall_digits(2, str + 6, x + 81, line + 1, true);
#else #else
// show the frequency in the main font // show the frequency in the main font
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); sprintf(str, "%03u.%05u", frequency / 100000, frequency % 100000);
#ifdef ENABLE_TRIM_TRAILING_ZEROS #ifdef ENABLE_TRIM_TRAILING_ZEROS
NUMBER_trim_trailing_zeros(String); NUMBER_trim_trailing_zeros(str);
#endif #endif
UI_PrintString(String, x, 0, line, 8); UI_PrintString(str, x, 0, line, 8);
#endif #endif
break; break;
case MDF_CHANNEL: // just channel number case MDF_CHANNEL: // just channel number
sprintf(String, "CH-%03u", g_eeprom.screen_channel[vfo_num] + 1); sprintf(str, "CH-%03u", g_eeprom.screen_channel[vfo_num] + 1);
UI_PrintString(String, x, 0, line, 8); UI_PrintString(str, x, 0, line, 8);
break; break;
case MDF_NAME: // channel name case MDF_NAME: // channel name
case MDF_NAME_FREQ: // channel name and frequency case MDF_NAME_FREQ: // channel name and frequency
BOARD_fetchChannelName(String, g_eeprom.screen_channel[vfo_num]); BOARD_fetchChannelName(str, g_eeprom.screen_channel[vfo_num]);
if (String[0] == 0) if (str[0] == 0)
{ // no channel name available, channel number instead { // no channel name available, channel number instead
sprintf(String, "CH-%03u", 1 + g_eeprom.screen_channel[vfo_num]); sprintf(str, "CH-%03u", 1 + g_eeprom.screen_channel[vfo_num]);
} }
if (g_eeprom.channel_display_mode == MDF_NAME) if (g_eeprom.channel_display_mode == MDF_NAME)
{ // just the name { // just the name
UI_PrintString(String, x + 4, 0, line, 8); UI_PrintString(str, x + 4, 0, line, 8);
} }
else else
{ // name & frequency { // name & frequency
// name // name
#ifdef ENABLE_SMALL_BOLD #ifdef ENABLE_SMALL_BOLD
UI_PrintStringSmallBold(String, x + 4, 0, line); UI_PrintStringSmallBold(str, x + 4, 0, line);
#else #else
UI_PrintStringSmall(String, x + 4, 0, line); UI_PrintStringSmall(str, x + 4, 0, line);
#endif #endif
// frequency // frequency
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); sprintf(str, "%03u.%05u", frequency / 100000, frequency % 100000);
#ifdef ENABLE_TRIM_TRAILING_ZEROS #ifdef ENABLE_TRIM_TRAILING_ZEROS
NUMBER_trim_trailing_zeros(String); NUMBER_trim_trailing_zeros(str);
#endif #endif
UI_PrintStringSmall(String, x + 4, 0, line + 1); UI_PrintStringSmall(str, x + 4, 0, line + 1);
} }
break; break;
@ -727,22 +727,22 @@ void UI_DisplayMain(void)
{ // frequency mode { // frequency mode
#ifdef ENABLE_BIG_FREQ #ifdef ENABLE_BIG_FREQ
NUMBER_ToDigits(frequency, String); // 8 digits NUMBER_ToDigits(frequency, str); // 8 digits
// show the main large frequency digits // show the main large frequency digits
UI_DisplayFrequency(String, x, line, false, false); UI_DisplayFrequency(str, x, line, false, false);
// show the remaining 2 small frequency digits // show the remaining 2 small frequency digits
UI_Displaysmall_digits(2, String + 6, x + 81, line + 1, true); UI_Displaysmall_digits(2, str + 6, x + 81, line + 1, true);
#else #else
// show the frequency in the main font // show the frequency in the main font
sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); sprintf(str, "%03u.%05u", frequency / 100000, frequency % 100000);
#ifdef ENABLE_TRIM_TRAILING_ZEROS #ifdef ENABLE_TRIM_TRAILING_ZEROS
NUMBER_trim_trailing_zeros(String); NUMBER_trim_trailing_zeros(str);
#endif #endif
UI_PrintString(String, x, 0, line, 8); UI_PrintString(str, x, 0, line, 8);
#endif #endif
} }
@ -758,11 +758,11 @@ void UI_DisplayMain(void)
const uint8_t attributes = g_user_channel_attributes[g_eeprom.screen_channel[vfo_num]]; const uint8_t attributes = g_user_channel_attributes[g_eeprom.screen_channel[vfo_num]];
if (attributes & USER_CH_SCANLIST1) if (attributes & USER_CH_SCANLIST1)
memmove(p_line0 + x, BITMAP_SCANLIST1, sizeof(BITMAP_SCANLIST1)); memcpy(p_line0 + x, BITMAP_SCANLIST1, sizeof(BITMAP_SCANLIST1));
x += sizeof(BITMAP_SCANLIST1); x += sizeof(BITMAP_SCANLIST1);
if (attributes & USER_CH_SCANLIST2) if (attributes & USER_CH_SCANLIST2)
memmove(p_line0 + x, BITMAP_SCANLIST2, sizeof(BITMAP_SCANLIST2)); memcpy(p_line0 + x, BITMAP_SCANLIST2, sizeof(BITMAP_SCANLIST2));
//x += sizeof(BITMAP_SCANLIST2); //x += sizeof(BITMAP_SCANLIST2);
} }
@ -779,8 +779,8 @@ void UI_DisplayMain(void)
//g_eeprom.vfo_info[vfo_num].freq_in_channel = BOARD_find_channel(frequency); //g_eeprom.vfo_info[vfo_num].freq_in_channel = BOARD_find_channel(frequency);
if (g_eeprom.vfo_info[vfo_num].freq_in_channel <= USER_CHANNEL_LAST) if (g_eeprom.vfo_info[vfo_num].freq_in_channel <= USER_CHANNEL_LAST)
{ // the channel number that contains this VFO frequency { // the channel number that contains this VFO frequency
sprintf(String, "%03u", 1 + g_eeprom.vfo_info[vfo_num].freq_in_channel); sprintf(str, "%03u", 1 + g_eeprom.vfo_info[vfo_num].freq_in_channel);
UI_PrintStringSmallest(String, x, (line + 0) * 8, false, true); UI_PrintStringSmallest(str, x, (line + 0) * 8, false, true);
} }
} }
x += smallest_char_spacing * 4; x += smallest_char_spacing * 4;
@ -821,10 +821,10 @@ void UI_DisplayMain(void)
// ************ // ************
String[0] = '\0'; str[0] = '\0';
if (g_eeprom.vfo_info[vfo_num].am_mode) if (g_eeprom.vfo_info[vfo_num].am_mode)
{ // show the AM symbol { // show the AM symbol
strcpy(String, "AM"); strcpy(str, "AM");
} }
else else
{ // or show the CTCSS/DCS symbol { // or show the CTCSS/DCS symbol
@ -832,26 +832,26 @@ void UI_DisplayMain(void)
const unsigned int code_type = pConfig->code_type; const unsigned int code_type = pConfig->code_type;
const char *code_list[] = {"", "CT", "DCS", "DCR"}; const char *code_list[] = {"", "CT", "DCS", "DCR"};
if (code_type < ARRAY_SIZE(code_list)) if (code_type < ARRAY_SIZE(code_list))
strcpy(String, code_list[code_type]); strcpy(str, code_list[code_type]);
} }
UI_PrintStringSmall(String, LCD_WIDTH + 24, 0, line + 1); UI_PrintStringSmall(str, LCD_WIDTH + 24, 0, line + 1);
if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM)
{ // show the TX power { // show the TX power
const char pwr_list[] = "LMH"; const char pwr_list[] = "LMH";
const unsigned int i = g_eeprom.vfo_info[vfo_num].output_power; const unsigned int i = g_eeprom.vfo_info[vfo_num].output_power;
String[0] = (i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0'; str[0] = (i < ARRAY_SIZE(pwr_list)) ? pwr_list[i] : '\0';
String[1] = '\0'; str[1] = '\0';
UI_PrintStringSmall(String, LCD_WIDTH + 46, 0, line + 1); UI_PrintStringSmall(str, LCD_WIDTH + 46, 0, line + 1);
} }
if (g_eeprom.vfo_info[vfo_num].freq_config_rx.frequency != g_eeprom.vfo_info[vfo_num].freq_config_tx.frequency) if (g_eeprom.vfo_info[vfo_num].freq_config_rx.frequency != g_eeprom.vfo_info[vfo_num].freq_config_tx.frequency)
{ // show the TX offset symbol { // show the TX offset symbol
const char dir_list[] = "\0+-"; const char dir_list[] = "\0+-";
const unsigned int i = g_eeprom.vfo_info[vfo_num].tx_offset_freq_dir; const unsigned int i = g_eeprom.vfo_info[vfo_num].tx_offset_freq_dir;
String[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?'; str[0] = (i < sizeof(dir_list)) ? dir_list[i] : '?';
String[1] = '\0'; str[1] = '\0';
UI_PrintStringSmall(String, LCD_WIDTH + 54, 0, line + 1); UI_PrintStringSmall(str, LCD_WIDTH + 54, 0, line + 1);
} }
// show the TX/RX reverse symbol // show the TX/RX reverse symbol
@ -859,13 +859,13 @@ void UI_DisplayMain(void)
UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1); UI_PrintStringSmall("R", LCD_WIDTH + 62, 0, line + 1);
{ // show the narrow band symbol { // show the narrow band symbol
String[0] = '\0'; str[0] = '\0';
if (g_eeprom.vfo_info[vfo_num].channel_bandwidth == BANDWIDTH_NARROW) if (g_eeprom.vfo_info[vfo_num].channel_bandwidth == BANDWIDTH_NARROW)
{ {
String[0] = 'N'; str[0] = 'N';
String[1] = '\0'; str[1] = '\0';
} }
UI_PrintStringSmall(String, LCD_WIDTH + 70, 0, line + 1); UI_PrintStringSmall(str, LCD_WIDTH + 70, 0, line + 1);
} }
// show the DTMF decoding symbol // show the DTMF decoding symbol
@ -917,8 +917,8 @@ void UI_DisplayMain(void)
return; return;
center_line = CENTER_LINE_AM_FIX_DATA; center_line = CENTER_LINE_AM_FIX_DATA;
AM_fix_print_data(g_eeprom.rx_vfo, String); AM_fix_print_data(g_eeprom.rx_vfo, str);
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(str, 2, 0, 3);
} }
else else
#endif #endif
@ -946,9 +946,9 @@ void UI_DisplayMain(void)
center_line = CENTER_LINE_DTMF_DEC; center_line = CENTER_LINE_DTMF_DEC;
strcpy(String, "DTMF "); strcpy(str, "DTMF ");
strcat(String, g_dtmf_rx_live + idx); strcat(str, g_dtmf_rx_live + idx);
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(str, 2, 0, 3);
} }
#else #else
if (g_setting_live_dtmf_decoder && g_dtmf_rx_index > 0) if (g_setting_live_dtmf_decoder && g_dtmf_rx_index > 0)
@ -961,9 +961,9 @@ void UI_DisplayMain(void)
center_line = CENTER_LINE_DTMF_DEC; center_line = CENTER_LINE_DTMF_DEC;
strcpy(String, "DTMF "); strcpy(str, "DTMF ");
strcat(String, g_dtmf_rx + idx); strcat(str, g_dtmf_rx + idx);
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(str, 2, 0, 3);
} }
#endif #endif
@ -976,10 +976,10 @@ void UI_DisplayMain(void)
center_line = CENTER_LINE_CHARGE_DATA; center_line = CENTER_LINE_CHARGE_DATA;
sprintf(String, "Charge %u.%02uV %u%%", sprintf(str, "Charge %u.%02uV %u%%",
g_battery_voltage_average / 100, g_battery_voltage_average % 100, g_battery_voltage_average / 100, g_battery_voltage_average % 100,
BATTERY_VoltsToPercent(g_battery_voltage_average)); BATTERY_VoltsToPercent(g_battery_voltage_average));
UI_PrintStringSmall(String, 2, 0, 3); UI_PrintStringSmall(str, 2, 0, 3);
} }
#endif #endif
} }

362
ui/menu.c
View File

@ -452,7 +452,7 @@ void UI_DisplayMenu(void)
const unsigned int sub_menu_x1 = (8 * menu_list_width) + 2; // start x corrd const unsigned int sub_menu_x1 = (8 * menu_list_width) + 2; // start x corrd
const unsigned int sub_menu_x2 = LCD_WIDTH - 1; // end x coord const unsigned int sub_menu_x2 = LCD_WIDTH - 1; // end x coord
unsigned int i; unsigned int i;
char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char) char str[64]; // bigger cuz we can now do multi-line in one string (use '\n' char)
// clear the screen buffer // clear the screen buffer
memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
@ -478,11 +478,11 @@ void UI_DisplayMenu(void)
// draw the little sub-menu triangle marker // draw the little sub-menu triangle marker
if (g_in_sub_menu) if (g_in_sub_menu)
memmove(g_frame_buffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); memcpy(g_frame_buffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator));
// draw the menu index number/count // draw the menu index number/count
sprintf(String, "%2u.%u", 1 + g_menu_cursor, g_menu_list_count); sprintf(str, "%2u.%u", 1 + g_menu_cursor, g_menu_list_count);
UI_PrintStringSmall(String, 2, 0, 6); UI_PrintStringSmall(str, 2, 0, 6);
#else #else
{ // new menu layout .. experimental & unfinished { // new menu layout .. experimental & unfinished
@ -520,21 +520,21 @@ void UI_DisplayMenu(void)
} }
// draw the menu index number/count // draw the menu index number/count
sprintf(String, "%2u.%u", 1 + g_menu_cursor, g_menu_list_count); sprintf(str, "%2u.%u", 1 + g_menu_cursor, g_menu_list_count);
UI_PrintStringSmall(String, 2, 0, 6); UI_PrintStringSmall(str, 2, 0, 6);
} }
else else
if (menu_index >= 0 && menu_index < (int)g_menu_list_count) if (menu_index >= 0 && menu_index < (int)g_menu_list_count)
{ // current menu item { // current menu item
strcpy(String, g_menu_list[g_menu_list_sorted[menu_index]].name); strcpy(str, g_menu_list[g_menu_list_sorted[menu_index]].name);
UI_PrintString(String, 0, 0, 0, 8); UI_PrintString(str, 0, 0, 0, 8);
} }
} }
#endif #endif
// ************** // **************
memset(String, 0, sizeof(String)); memset(str, 0, sizeof(str));
bool already_printed = false; bool already_printed = false;
@ -544,15 +544,15 @@ void UI_DisplayMenu(void)
switch (g_menu_cursor) switch (g_menu_cursor)
{ {
case MENU_SQL: case MENU_SQL:
strcpy(String, "MAIN SQL\n"); strcpy(str, "MAIN SQL\n");
sprintf(String + strlen(String), "%d\n ", g_sub_menu_selection); sprintf(str + strlen(str), "%d\n ", g_sub_menu_selection);
break; break;
case MENU_CHAN_SQL: case MENU_CHAN_SQL:
if (g_sub_menu_selection == 0) if (g_sub_menu_selection == 0)
strcpy(String, "USE\nMAIN SQL"); strcpy(str, "USE\nMAIN SQL");
else else
sprintf(String, "%d", g_sub_menu_selection); sprintf(str, "%d", g_sub_menu_selection);
// g_tx_vfo->squelch_level = g_sub_menu_selection; // g_tx_vfo->squelch_level = g_sub_menu_selection;
// RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo); // RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo);
break; break;
@ -560,7 +560,7 @@ void UI_DisplayMenu(void)
case MENU_MIC_GAIN: case MENU_MIC_GAIN:
{ // display the mic gain in actual dB rather than just an index number { // display the mic gain in actual dB rather than just an index number
const uint8_t mic = g_mic_gain_dB_2[g_sub_menu_selection]; const uint8_t mic = g_mic_gain_dB_2[g_sub_menu_selection];
sprintf(String, "+%u.%udB", mic / 2, mic % 2); sprintf(str, "+%u.%udB", mic / 2, mic % 2);
} }
break; break;
@ -570,44 +570,44 @@ void UI_DisplayMenu(void)
const uint32_t step = (uint32_t)STEP_FREQ_TABLE[step_freq_table_sorted[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) if (step < 1000)
{ // Hz { // Hz
sprintf(String, "%uHz", step); sprintf(str, "%uHz", step);
} }
else else
{ // kHz { // kHz
sprintf(String, "%u.%03u", step / 1000, step % 1000); sprintf(str, "%u.%03u", step / 1000, step % 1000);
NUMBER_trim_trailing_zeros(String); NUMBER_trim_trailing_zeros(str);
strcat(String, "kHz"); strcat(str, "kHz");
} }
break; break;
} }
case MENU_TX_POWER: case MENU_TX_POWER:
strcpy(String, g_sub_menu_tx_power[g_sub_menu_selection]); strcpy(str, g_sub_menu_tx_power[g_sub_menu_selection]);
break; break;
case MENU_RX_CDCSS: case MENU_RX_CDCSS:
case MENU_TX_CDCSS: case MENU_TX_CDCSS:
strcpy(String, "CDCSS\n"); strcpy(str, "CDCSS\n");
if (g_sub_menu_selection == 0) if (g_sub_menu_selection == 0)
strcat(String, "OFF"); strcat(str, "OFF");
else else
if (g_sub_menu_selection < 105) if (g_sub_menu_selection < 105)
sprintf(String + strlen(String), "D%03oN", DCS_OPTIONS[g_sub_menu_selection - 1]); sprintf(str + strlen(str), "D%03oN", DCS_OPTIONS[g_sub_menu_selection - 1]);
else else
sprintf(String + strlen(String), "D%03oI", DCS_OPTIONS[g_sub_menu_selection - 105]); sprintf(str + strlen(str), "D%03oI", DCS_OPTIONS[g_sub_menu_selection - 105]);
break; break;
case MENU_RX_CTCSS: case MENU_RX_CTCSS:
case MENU_TX_CTCSS: case MENU_TX_CTCSS:
{ {
strcpy(String, "CTCSS\n"); strcpy(str, "CTCSS\n");
#if 1 #if 1
// set CTCSS as the user adjusts it // set CTCSS as the user adjusts it
unsigned int Code; unsigned int Code;
freq_config_t *pConfig = (g_menu_cursor == MENU_RX_CTCSS) ? &g_tx_vfo->freq_config_rx : &g_tx_vfo->freq_config_tx; freq_config_t *pConfig = (g_menu_cursor == MENU_RX_CTCSS) ? &g_tx_vfo->freq_config_rx : &g_tx_vfo->freq_config_tx;
if (g_sub_menu_selection == 0) if (g_sub_menu_selection == 0)
{ {
strcat(String, "OFF"); strcat(str, "OFF");
if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE) if (pConfig->code_type != CODE_TYPE_CONTINUOUS_TONE)
break; break;
@ -620,7 +620,7 @@ void UI_DisplayMenu(void)
} }
else else
{ {
sprintf(String + strlen(String), "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10); sprintf(str + strlen(str), "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10);
pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE; pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE;
Code = g_sub_menu_selection - 1; Code = g_sub_menu_selection - 1;
@ -630,37 +630,37 @@ void UI_DisplayMenu(void)
} }
#else #else
if (g_sub_menu_selection == 0) if (g_sub_menu_selection == 0)
strcat(String, "OFF"); strcat(str, "OFF");
else else
sprintf(String + strlen(String), "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10); sprintf(str + strlen(str), "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10);
#endif #endif
break; break;
} }
case MENU_SHIFT_DIR: case MENU_SHIFT_DIR:
strcpy(String, g_sub_menu_shift_dir[g_sub_menu_selection]); strcpy(str, g_sub_menu_shift_dir[g_sub_menu_selection]);
break; break;
case MENU_OFFSET: case MENU_OFFSET:
if (!g_in_sub_menu || g_input_box_index == 0) if (!g_in_sub_menu || g_input_box_index == 0)
{ {
sprintf(String, "%d.%05u", g_sub_menu_selection / 100000, abs(g_sub_menu_selection) % 100000); sprintf(str, "%d.%05u", g_sub_menu_selection / 100000, abs(g_sub_menu_selection) % 100000);
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 1, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 1, 8);
} }
else else
{ {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
String[i + 0] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0'; str[i + 0] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0';
String[3] = '.'; str[3] = '.';
for (i = 3; i < 6; i++) for (i = 3; i < 6; i++)
String[i + 1] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0'; str[i + 1] = (g_input_box[i] == 10) ? '-' : g_input_box[i] + '0';
String[ 7] = '-'; str[ 7] = '-';
String[ 8] = '-'; str[ 8] = '-';
String[ 9] = 0; str[ 9] = 0;
String[10] = 0; str[10] = 0;
String[11] = 0; str[11] = 0;
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 1, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 1, 8);
} }
UI_PrintString("MHz", sub_menu_x1, sub_menu_x2, 3, 8); UI_PrintString("MHz", sub_menu_x1, sub_menu_x2, 3, 8);
@ -669,12 +669,12 @@ void UI_DisplayMenu(void)
break; break;
case MENU_BANDWIDTH: case MENU_BANDWIDTH:
strcpy(String, g_sub_menu_bandwidth[g_sub_menu_selection]); strcpy(str, g_sub_menu_bandwidth[g_sub_menu_selection]);
break; break;
case MENU_SCRAMBLER: case MENU_SCRAMBLER:
strcpy(String, "INVERT\n"); strcpy(str, "INVERT\n");
strcat(String, g_sub_menu_scrambler[g_sub_menu_selection]); strcat(str, g_sub_menu_scrambler[g_sub_menu_selection]);
#if 1 #if 1
if (g_sub_menu_selection > 0 && g_setting_scramble_enable) if (g_sub_menu_selection > 0 && g_setting_scramble_enable)
@ -687,29 +687,29 @@ void UI_DisplayMenu(void)
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
case MENU_VOX: case MENU_VOX:
if (g_sub_menu_selection == 0) if (g_sub_menu_selection == 0)
strcpy(String, "OFF"); strcpy(str, "OFF");
else else
sprintf(String, "%d", g_sub_menu_selection); sprintf(str, "%d", g_sub_menu_selection);
break; break;
#endif #endif
case MENU_AUTO_BACKLITE: case MENU_AUTO_BACKLITE:
strcpy(String, "BACKLITE\n"); strcpy(str, "BACKLITE\n");
strcat(String, g_sub_menu_backlight[g_sub_menu_selection]); strcat(str, g_sub_menu_backlight[g_sub_menu_selection]);
break; break;
case MENU_AUTO_BACKLITE_ON_TX_RX: case MENU_AUTO_BACKLITE_ON_TX_RX:
strcpy(String, "BACKLITE\n"); strcpy(str, "BACKLITE\n");
strcat(String, g_sub_menu_rx_tx[g_sub_menu_selection]); strcat(str, g_sub_menu_rx_tx[g_sub_menu_selection]);
break; break;
case MENU_MOD_MODE: case MENU_MOD_MODE:
strcpy(String, (g_sub_menu_selection == 0) ? "FM" : "AM"); strcpy(str, (g_sub_menu_selection == 0) ? "FM" : "AM");
break; break;
#ifdef ENABLE_AM_FIX_TEST1 #ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1: case MENU_AM_FIX_TEST1:
strcpy(String, g_sub_menu_AM_FIX_test1[g_sub_menu_selection]); strcpy(str, g_sub_menu_AM_FIX_test1[g_sub_menu_selection]);
// g_setting_am_fix = g_sub_menu_selection; // g_setting_am_fix = g_sub_menu_selection;
break; break;
#endif #endif
@ -717,20 +717,20 @@ void UI_DisplayMenu(void)
#ifdef ENABLE_KEYLOCK #ifdef ENABLE_KEYLOCK
case MENU_AUTO_KEY_LOCK: case MENU_AUTO_KEY_LOCK:
if (g_sub_menu_selection == 0) if (g_sub_menu_selection == 0)
strcpy(String, "OFF"); strcpy(str, "OFF");
else else
sprintf(String, "%u secs", key_lock_timeout_500ms / 2); sprintf(str, "%u secs", key_lock_timeout_500ms / 2);
break; break;
#endif #endif
case MENU_COMPAND: case MENU_COMPAND:
strcpy(String, g_sub_menu_rx_tx[g_sub_menu_selection]); strcpy(str, g_sub_menu_rx_tx[g_sub_menu_selection]);
break; break;
#ifdef ENABLE_CONTRAST #ifdef ENABLE_CONTRAST
case MENU_CONTRAST: case MENU_CONTRAST:
strcpy(String, "CONTRAST\n"); strcpy(str, "CONTRAST\n");
sprintf(String + strlen(String), "%d", g_sub_menu_selection); sprintf(str + strlen(str), "%d", g_sub_menu_selection);
//g_setting_contrast = g_sub_menu_selection //g_setting_contrast = g_sub_menu_selection
ST7565_SetContrast(g_sub_menu_selection); ST7565_SetContrast(g_sub_menu_selection);
g_update_display = true; g_update_display = true;
@ -748,70 +748,70 @@ void UI_DisplayMenu(void)
#endif #endif
case MENU_S_ADD1: case MENU_S_ADD1:
case MENU_S_ADD2: case MENU_S_ADD2:
strcpy(String, g_sub_menu_off_on[g_sub_menu_selection]); strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);
break; break;
case MENU_BUSY_CHAN_LOCK: case MENU_BUSY_CHAN_LOCK:
strcpy(String, "BSY CH TX\nLOCKOUT\n"); strcpy(str, "BSY CH TX\nLOCKOUT\n");
strcat(String, g_sub_menu_off_on[g_sub_menu_selection]); strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
break; break;
case MENU_DTMF_DCD: case MENU_DTMF_DCD:
case MENU_DTMF_LIVE_DEC: case MENU_DTMF_LIVE_DEC:
strcpy(String, "DTMF\nDECODE\n"); strcpy(str, "DTMF\nDECODE\n");
strcat(String, g_sub_menu_off_on[g_sub_menu_selection]); strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
break; break;
case MENU_STE: case MENU_STE:
strcpy(String, "SUB TAIL\nELIMIN\n"); strcpy(str, "SUB TAIL\nELIMIN\n");
strcat(String, g_sub_menu_off_on[g_sub_menu_selection]); strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
break; break;
case MENU_BEEP: case MENU_BEEP:
strcpy(String, "KEY BEEP\n"); strcpy(str, "KEY BEEP\n");
strcat(String + strlen(String), g_sub_menu_off_on[g_sub_menu_selection]); strcat(str + strlen(str), g_sub_menu_off_on[g_sub_menu_selection]);
break; break;
case MENU_DTMF_ST: case MENU_DTMF_ST:
strcpy(String, "DTMF\nSIDETONE\n"); strcpy(str, "DTMF\nSIDETONE\n");
strcat(String, g_sub_menu_off_on[g_sub_menu_selection]); strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
break; break;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
case MENU_NOAA_SCAN: case MENU_NOAA_SCAN:
strcpy(String, "SCAN\n"); strcpy(str, "SCAN\n");
strcat(String, g_sub_menu_dis_en[g_sub_menu_selection]); strcat(str, g_sub_menu_dis_en[g_sub_menu_selection]);
break; break;
#endif #endif
case MENU_350_EN: case MENU_350_EN:
strcpy(String, "350~400\n"); strcpy(str, "350~400\n");
strcat(String, g_sub_menu_dis_en[g_sub_menu_selection]); strcat(str, g_sub_menu_dis_en[g_sub_menu_selection]);
break; break;
case MENU_350_TX: case MENU_350_TX:
strcpy(String, "TX\n350~400\n"); strcpy(str, "TX\n350~400\n");
strcat(String, g_sub_menu_dis_en[g_sub_menu_selection]); strcat(str, g_sub_menu_dis_en[g_sub_menu_selection]);
break; break;
case MENU_174_TX: case MENU_174_TX:
strcpy(String, "TX\n174~350\n"); strcpy(str, "TX\n174~350\n");
strcat(String, g_sub_menu_dis_en[g_sub_menu_selection]); strcat(str, g_sub_menu_dis_en[g_sub_menu_selection]);
break; break;
case MENU_470_TX: case MENU_470_TX:
strcpy(String, "TX\n470~600\n"); strcpy(str, "TX\n470~600\n");
strcat(String, g_sub_menu_dis_en[g_sub_menu_selection]); strcat(str, g_sub_menu_dis_en[g_sub_menu_selection]);
break; break;
case MENU_SCRAMBLER_EN: case MENU_SCRAMBLER_EN:
strcpy(String, "SCRAMBLER\n"); strcpy(str, "SCRAMBLER\n");
strcat(String, g_sub_menu_dis_en[g_sub_menu_selection]); strcat(str, g_sub_menu_dis_en[g_sub_menu_selection]);
break; break;
case MENU_TX_EN: case MENU_TX_EN:
strcpy(String, "TX\n"); strcpy(str, "TX\n");
strcat(String, g_sub_menu_dis_en[g_sub_menu_selection]); strcat(str, g_sub_menu_dis_en[g_sub_menu_selection]);
break; break;
case MENU_MEM_SAVE: case MENU_MEM_SAVE:
@ -821,17 +821,17 @@ 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 ? "CH-" : "", g_sub_menu_selection); UI_GenerateChannelStringEx(str, valid ? "CH-" : "", g_sub_menu_selection);
// channel name // channel name
BOARD_fetchChannelName(s, g_sub_menu_selection); BOARD_fetchChannelName(s, g_sub_menu_selection);
strcat(String, "\n"); strcat(str, "\n");
strcat(String, (s[0] == 0) ? "--" : s); strcat(str, (s[0] == 0) ? "--" : s);
if (valid && !g_ask_for_confirmation) if (valid && !g_ask_for_confirmation)
{ // show the frequency so that the user knows the channels frequency { // show the frequency so that the user knows the channels frequency
const uint32_t frequency = BOARD_fetchChannelFrequency(g_sub_menu_selection); const uint32_t frequency = BOARD_fetchChannelFrequency(g_sub_menu_selection);
sprintf(String + strlen(String), "\n%u.%05u", frequency / 100000, frequency % 100000); sprintf(str + strlen(str), "\n%u.%05u", frequency / 100000, frequency % 100000);
} }
break; break;
@ -842,8 +842,8 @@ 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_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(String, valid ? "CH-" : "", g_sub_menu_selection); UI_GenerateChannelStringEx(str, valid ? "CH-" : "", g_sub_menu_selection);
UI_PrintString(String, sub_menu_x1, sub_menu_x2, y, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, y, 8);
if (valid) if (valid)
{ {
@ -851,10 +851,10 @@ void UI_DisplayMenu(void)
if (!g_in_sub_menu || g_edit_index < 0) if (!g_in_sub_menu || g_edit_index < 0)
{ // show the channel name { // show the channel name
BOARD_fetchChannelName(String, g_sub_menu_selection); BOARD_fetchChannelName(str, g_sub_menu_selection);
if (String[0] == 0) if (str[0] == 0)
strcpy(String, "--"); strcpy(str, "--");
UI_PrintString(String, sub_menu_x1, sub_menu_x2, y + 2, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, y + 2, 8);
} }
else else
{ // show the channel name being edited { // show the channel name being edited
@ -865,11 +865,11 @@ void UI_DisplayMenu(void)
if (!g_ask_for_confirmation) if (!g_ask_for_confirmation)
{ // show the frequency so that the user knows the channels frequency { // show the frequency so that the user knows the channels frequency
sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); sprintf(str, "%u.%05u", frequency / 100000, frequency % 100000);
if (!g_in_sub_menu || g_edit_index < 0) if (!g_in_sub_menu || g_edit_index < 0)
UI_PrintString(String, sub_menu_x1, sub_menu_x2, y + 4, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, y + 4, 8);
else else
UI_PrintString(String, sub_menu_x1, sub_menu_x2, y + 5, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, y + 5, 8);
} }
} }
@ -878,81 +878,81 @@ void UI_DisplayMenu(void)
} }
case MENU_BAT_SAVE: case MENU_BAT_SAVE:
strcpy(String, g_sub_menu_bat_save[g_sub_menu_selection]); strcpy(str, g_sub_menu_bat_save[g_sub_menu_selection]);
break; break;
case MENU_DUAL_WATCH: case MENU_DUAL_WATCH:
// strcpy(String, g_sub_menu_dual_watch[g_sub_menu_selection]); // strcpy(String, g_sub_menu_dual_watch[g_sub_menu_selection]);
strcpy(String, g_sub_menu_off_on[g_sub_menu_selection]); strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);
break; break;
case MENU_SCAN_HOLD: case MENU_SCAN_HOLD:
strcpy(String, "SCAN HOLD\n"); strcpy(str, "SCAN HOLD\n");
sprintf(String + strlen(String), "%d.%d sec", g_sub_menu_selection / 2, 5 * (g_sub_menu_selection % 2)); sprintf(str + strlen(str), "%d.%d sec", g_sub_menu_selection / 2, 5 * (g_sub_menu_selection % 2));
break; break;
case MENU_CROSS_VFO: case MENU_CROSS_VFO:
strcpy(String, g_sub_menu_cross_vfo[g_sub_menu_selection]); strcpy(str, g_sub_menu_cross_vfo[g_sub_menu_selection]);
break; break;
case MENU_TX_TO: case MENU_TX_TO:
strcpy(String, g_sub_menu_tx_timeout[g_sub_menu_selection]); strcpy(str, g_sub_menu_tx_timeout[g_sub_menu_selection]);
break; break;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
case MENU_VOICE: case MENU_VOICE:
strcpy(String, g_sub_menu_voice[g_sub_menu_selection]); strcpy(str, g_sub_menu_voice[g_sub_menu_selection]);
break; break;
#endif #endif
case MENU_SCAN_CAR_RESUME: case MENU_SCAN_CAR_RESUME:
strcpy(String, "SCAN\nRESUME\n"); strcpy(str, "SCAN\nRESUME\n");
strcat(String, g_sub_menu_scan_car_resume[g_sub_menu_selection]); strcat(str, g_sub_menu_scan_car_resume[g_sub_menu_selection]);
break; break;
case MENU_MEM_DISP: case MENU_MEM_DISP:
strcpy(String, g_sub_menu_mem_disp[g_sub_menu_selection]); strcpy(str, g_sub_menu_mem_disp[g_sub_menu_selection]);
break; break;
case MENU_RP_STE: case MENU_RP_STE:
if (g_sub_menu_selection == 0) if (g_sub_menu_selection == 0)
strcpy(String, "OFF"); strcpy(str, "OFF");
else else
sprintf(String, "%d*100ms", g_sub_menu_selection); sprintf(str, "%d*100ms", g_sub_menu_selection);
break; break;
case MENU_S_LIST: case MENU_S_LIST:
if (g_sub_menu_selection < 2) if (g_sub_menu_selection < 2)
sprintf(String, "LIST%u", 1 + g_sub_menu_selection); sprintf(str, "LIST%u", 1 + g_sub_menu_selection);
else else
strcpy(String, "ALL"); strcpy(str, "ALL");
break; break;
#ifdef ENABLE_ALARM #ifdef ENABLE_ALARM
case MENU_ALARM_MODE: case MENU_ALARM_MODE:
strcpy(String, "TX ALARM\n"); strcpy(str, "TX ALARM\n");
sprintf(String + strlen(String), g_sub_menu_alarm_mode[g_sub_menu_selection]); sprintf(str + strlen(str), g_sub_menu_alarm_mode[g_sub_menu_selection]);
break; break;
#endif #endif
case MENU_ANI_ID: case MENU_ANI_ID:
strcpy(String, "YOUR ID\n"); strcpy(str, "YOUR ID\n");
strcat(String, g_eeprom.ani_dtmf_id); strcat(str, g_eeprom.ani_dtmf_id);
break; break;
case MENU_UP_CODE: case MENU_UP_CODE:
strcpy(String, "PTT DTMF\nBEGIN\n"); strcpy(str, "PTT DTMF\nBEGIN\n");
strcat(String, g_eeprom.dtmf_key_up_code); strcat(str, g_eeprom.dtmf_key_up_code);
break; break;
case MENU_DN_CODE: case MENU_DN_CODE:
strcpy(String, "PTT DTMF\nEND\n"); strcpy(str, "PTT DTMF\nEND\n");
strcat(String, g_eeprom.dtmf_key_down_code); strcat(str, g_eeprom.dtmf_key_down_code);
break; break;
case MENU_DTMF_RSP: case MENU_DTMF_RSP:
strcpy(String, "DTMF\nRESPONSE\n"); strcpy(str, "DTMF\nRESPONSE\n");
strcat(String, g_sub_menu_dtmf_rsp[g_sub_menu_selection]); strcat(str, g_sub_menu_dtmf_rsp[g_sub_menu_selection]);
break; break;
case MENU_DTMF_HOLD: case MENU_DTMF_HOLD:
@ -975,58 +975,58 @@ void UI_DisplayMenu(void)
case 61: g_sub_menu_selection = 5; break; case 61: g_sub_menu_selection = 5; break;
} }
strcpy(String, "DTMF MSG\n"); strcpy(str, "DTMF MSG\n");
if (g_sub_menu_selection < DTMF_HOLD_MAX) if (g_sub_menu_selection < DTMF_HOLD_MAX)
sprintf(String + strlen(String), "%d sec", g_sub_menu_selection); sprintf(str + strlen(str), "%d sec", g_sub_menu_selection);
else else
strcat(String, "STAY ON\nSCREEN"); // 60 strcat(str, "STAY ON\nSCREEN"); // 60
break; break;
case MENU_DTMF_PRE: case MENU_DTMF_PRE:
strcpy(String, "TX DTMF\nDELAY\n"); strcpy(str, "TX DTMF\nDELAY\n");
// sprintf(String + strlen(String), "%d*10ms", g_sub_menu_selection); // sprintf(String + strlen(String), "%d*10ms", g_sub_menu_selection);
sprintf(String + strlen(String), "%dms", 10 * g_sub_menu_selection); sprintf(str + strlen(str), "%dms", 10 * g_sub_menu_selection);
break; break;
case MENU_PTT_ID: case MENU_PTT_ID:
strcpy(String, (g_sub_menu_selection > 0) ? "TX ID\n" : ""); strcpy(str, (g_sub_menu_selection > 0) ? "TX ID\n" : "");
strcat(String, g_sub_menu_ptt_id[g_sub_menu_selection]); strcat(str, g_sub_menu_ptt_id[g_sub_menu_selection]);
break; break;
case MENU_BAT_TXT: case MENU_BAT_TXT:
strcpy(String, g_sub_menu_bat_text[g_sub_menu_selection]); strcpy(str, g_sub_menu_bat_text[g_sub_menu_selection]);
break; break;
case MENU_DTMF_LIST: case MENU_DTMF_LIST:
{ {
char Contact[17]; char Contact[17];
g_dtmf_is_contact_valid = DTMF_GetContact((int)g_sub_menu_selection - 1, Contact); g_dtmf_is_contact_valid = DTMF_GetContact((int)g_sub_menu_selection - 1, Contact);
strcpy(String, "DTMF\n"); strcpy(str, "DTMF\n");
if (!g_dtmf_is_contact_valid) if (!g_dtmf_is_contact_valid)
{ {
strcat(String, "NULL"); strcat(str, "NULL");
} }
else else
{ {
memmove(String + strlen(String), Contact, 8); memcpy(str + strlen(str), Contact, 8);
Contact[11] = 0; Contact[11] = 0;
memmove(&g_dtmf_id, Contact + 8, 4); memcpy(&g_dtmf_id, Contact + 8, sizeof(g_dtmf_id));
sprintf(String + strlen(String), "\nID:%s", Contact + 8); sprintf(str + strlen(str), "\nID:%s", Contact + 8);
} }
break; break;
} }
case MENU_PON_MSG: case MENU_PON_MSG:
strcpy(String, g_sub_menu_pwr_on_msg[g_sub_menu_selection]); strcpy(str, g_sub_menu_pwr_on_msg[g_sub_menu_selection]);
break; break;
case MENU_ROGER_MODE: case MENU_ROGER_MODE:
strcpy(String, g_sub_menu_roger_mode[g_sub_menu_selection]); strcpy(str, g_sub_menu_roger_mode[g_sub_menu_selection]);
break; break;
case MENU_VOLTAGE: case MENU_VOLTAGE:
sprintf(String, "%u.%02uV\n%u%%\ncurr %u", sprintf(str, "%u.%02uV\n%u%%\ncurr %u",
g_battery_voltage_average / 100, g_battery_voltage_average % 100, g_battery_voltage_average / 100, g_battery_voltage_average % 100,
BATTERY_VoltsToPercent(g_battery_voltage_average), BATTERY_VoltsToPercent(g_battery_voltage_average),
g_usb_current); g_usb_current);
@ -1037,7 +1037,7 @@ void UI_DisplayMenu(void)
case MENU_SIDE1_LONG: case MENU_SIDE1_LONG:
case MENU_SIDE2_SHORT: case MENU_SIDE2_SHORT:
case MENU_SIDE2_LONG: case MENU_SIDE2_LONG:
strcpy(String, g_sub_menu_side_butt[g_sub_menu_selection]); strcpy(str, g_sub_menu_side_butt[g_sub_menu_selection]);
break; break;
#endif #endif
@ -1047,69 +1047,69 @@ void UI_DisplayMenu(void)
unsigned int m = 0; unsigned int m = 0;
unsigned int k = 0; unsigned int k = 0;
i = 0; i = 0;
while (i < (sizeof(String) - 1) && k < slen) while (i < (sizeof(str) - 1) && k < slen)
{ {
const char c = Version_str[k++]; const char c = Version_str[k++];
if (c == ' ' || c == '-' || c == '_') if (c == ' ' || c == '-' || c == '_')
{ {
if (m >= 3) if (m >= 3)
{ {
String[i++] = '\n'; str[i++] = '\n';
m = 0; m = 0;
} }
else else
String[i++] = c; str[i++] = c;
} }
else else
{ {
String[i++] = c; str[i++] = c;
if (++m >= 9 && k < slen && i < (sizeof(String) - 1)) if (++m >= 9 && k < slen && i < (sizeof(str) - 1))
{ {
if (m > 0) if (m > 0)
{ {
m = 0; m = 0;
String[i++] = '\n'; str[i++] = '\n';
} }
} }
} }
} }
// add the date and time // add the date and time
strcat(String, "\n \n" __DATE__ "\n" __TIME__); strcat(str, "\n \n" __DATE__ "\n" __TIME__);
break; break;
} }
case MENU_RESET: case MENU_RESET:
strcpy(String, g_sub_menu_reset[g_sub_menu_selection]); strcpy(str, g_sub_menu_reset[g_sub_menu_selection]);
break; break;
case MENU_FREQ_LOCK: case MENU_FREQ_LOCK:
switch (g_sub_menu_selection) switch (g_sub_menu_selection)
{ {
case FREQ_LOCK_NORMAL: case FREQ_LOCK_NORMAL:
strcpy(String, "137~174\n400~470\n+ others"); strcpy(str, "137~174\n400~470\n+ others");
break; break;
case FREQ_LOCK_FCC: case FREQ_LOCK_FCC:
strcpy(String, "FCC HAM\n144~148\n420~450"); strcpy(str, "FCC HAM\n144~148\n420~450");
break; break;
case FREQ_LOCK_CE: case FREQ_LOCK_CE:
strcpy(String, "CE HAM\n144~146\n430~440"); strcpy(str, "CE HAM\n144~146\n430~440");
break; break;
case FREQ_LOCK_GB: case FREQ_LOCK_GB:
strcpy(String, "GB HAM\n144~148\n430~440"); strcpy(str, "GB HAM\n144~148\n430~440");
break; break;
case FREQ_LOCK_430: case FREQ_LOCK_430:
strcpy(String, "137~174\n400~430"); strcpy(str, "137~174\n400~430");
break; break;
case FREQ_LOCK_438: case FREQ_LOCK_438:
strcpy(String, "137~174\n400~438"); strcpy(str, "137~174\n400~438");
break; break;
case FREQ_LOCK_446: case FREQ_LOCK_446:
strcpy(String, "446.00625\n~\n446.19375"); strcpy(str, "446.00625\n~\n446.19375");
break; break;
#ifdef ENABLE_TX_UNLOCK #ifdef ENABLE_TX_UNLOCK
case FREQ_LOCK_TX_UNLOCK: case FREQ_LOCK_TX_UNLOCK:
sprintf(String, "UNLOCKED\n%u~%u", BX4819_BAND1.lower / 100000, BX4819_BAND2.upper / 100000); sprintf(str, "UNLOCKED\n%u~%u", BX4819_BAND1.lower / 100000, BX4819_BAND2.upper / 100000);
break; break;
#endif #endif
} }
@ -1123,7 +1123,7 @@ void UI_DisplayMenu(void)
writeXtalFreqCal(g_sub_menu_selection, false); writeXtalFreqCal(g_sub_menu_selection, false);
sprintf(String, "%d\n%u.%06u\nMHz", sprintf(str, "%d\n%u.%06u\nMHz",
g_sub_menu_selection, g_sub_menu_selection,
xtal_Hz / 1000000, xtal_Hz % 1000000); xtal_Hz / 1000000, xtal_Hz % 1000000);
} }
@ -1134,9 +1134,9 @@ void UI_DisplayMenu(void)
{ {
const uint16_t vol = (uint32_t)g_battery_voltage_average * g_battery_calibration[3] / g_sub_menu_selection; const uint16_t vol = (uint32_t)g_battery_voltage_average * g_battery_calibration[3] / g_sub_menu_selection;
if (!g_in_sub_menu) if (!g_in_sub_menu)
sprintf(String, "%u.%02uV\n%d", vol / 100, vol % 100, g_sub_menu_selection); sprintf(str, "%u.%02uV\n%d", vol / 100, vol % 100, g_sub_menu_selection);
else else
sprintf(String, "%u.%02uV\n(%#4d)\n%#4d", vol / 100, vol % 100, g_battery_calibration[3], g_sub_menu_selection); sprintf(str, "%u.%02uV\n(%#4d)\n%#4d", vol / 100, vol % 100, g_battery_calibration[3], g_sub_menu_selection);
break; break;
} }
} }
@ -1148,7 +1148,7 @@ void UI_DisplayMenu(void)
unsigned int y; unsigned int y;
unsigned int lines = 1; unsigned int lines = 1;
unsigned int len = strlen(String); unsigned int len = strlen(str);
bool small = false; bool small = false;
if (len > 0) if (len > 0)
@ -1156,10 +1156,10 @@ void UI_DisplayMenu(void)
// count number of lines // count number of lines
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
if (String[i] == '\n' && i < (len - 1)) if (str[i] == '\n' && i < (len - 1))
{ // found new line char { // found new line char
lines++; lines++;
String[i] = 0; // null terminate the line str[i] = 0; // null terminate the line
} }
} }
@ -1180,16 +1180,16 @@ void UI_DisplayMenu(void)
for (i = 0; i < len && lines > 0; lines--) for (i = 0; i < len && lines > 0; lines--)
{ {
if (small) if (small)
UI_PrintStringSmall(String + i, sub_menu_x1, sub_menu_x2, y); UI_PrintStringSmall(str + i, sub_menu_x1, sub_menu_x2, y);
else else
UI_PrintString(String + i, sub_menu_x1, sub_menu_x2, y, 8); UI_PrintString(str + i, sub_menu_x1, sub_menu_x2, y, 8);
// look for start of next line // look for start of next line
while (i < len && String[i] >= 32) while (i < len && str[i] >= 32)
i++; i++;
// hop over the null term char(s) // hop over the null term char(s)
while (i < len && String[i] < 32) while (i < len && str[i] < 32)
i++; i++;
y += small ? 1 : 2; y += small ? 1 : 2;
@ -1203,43 +1203,43 @@ void UI_DisplayMenu(void)
// if (g_sub_menu_selection == 0xFF) // if (g_sub_menu_selection == 0xFF)
if (g_sub_menu_selection < 0) if (g_sub_menu_selection < 0)
strcpy(String, "NULL"); strcpy(str, "NULL");
else else
UI_GenerateChannelStringEx(String, "CH-", g_sub_menu_selection); UI_GenerateChannelStringEx(str, "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])
{ {
// channel number // channel number
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 0, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 0, 8);
// channel name // channel name
BOARD_fetchChannelName(String, g_sub_menu_selection); BOARD_fetchChannelName(str, g_sub_menu_selection);
if (String[0] == 0) if (str[0] == 0)
strcpy(String, "--"); strcpy(str, "--");
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 2, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 2, 8);
} }
else else
{ {
// channel number // channel number
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 0, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 0, 8);
// channel name // channel name
BOARD_fetchChannelName(String, g_sub_menu_selection); BOARD_fetchChannelName(str, g_sub_menu_selection);
if (String[0] == 0) if (str[0] == 0)
strcpy(String, "--"); strcpy(str, "--");
UI_PrintStringSmall(String, sub_menu_x1, sub_menu_x2, 2); UI_PrintStringSmall(str, sub_menu_x1, sub_menu_x2, 2);
if (IS_USER_CHANNEL(g_eeprom.scan_list_priority_ch1[i])) if (IS_USER_CHANNEL(g_eeprom.scan_list_priority_ch1[i]))
{ {
sprintf(String, "PRI1:%u", g_eeprom.scan_list_priority_ch1[i] + 1); sprintf(str, "PRI1:%u", g_eeprom.scan_list_priority_ch1[i] + 1);
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 3, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 3, 8);
} }
if (IS_USER_CHANNEL(g_eeprom.scan_list_priority_ch2[i])) if (IS_USER_CHANNEL(g_eeprom.scan_list_priority_ch2[i]))
{ {
sprintf(String, "PRI2:%u", g_eeprom.scan_list_priority_ch2[i] + 1); sprintf(str, "PRI2:%u", g_eeprom.scan_list_priority_ch2[i] + 1);
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 5, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 5, 8);
} }
} }
} }
@ -1264,9 +1264,9 @@ void UI_DisplayMenu(void)
if (g_in_sub_menu) if (g_in_sub_menu)
{ {
unsigned int Offset; unsigned int Offset;
NUMBER_ToDigits(g_sub_menu_selection, String); NUMBER_ToDigits(g_sub_menu_selection, str);
Offset = (g_menu_cursor == MENU_DTMF_LIST) ? 2 : 3; Offset = (g_menu_cursor == MENU_DTMF_LIST) ? 2 : 3;
UI_Displaysmall_digits(Offset, String + (8 - Offset), 105, 0, false); UI_Displaysmall_digits(Offset, str + (8 - Offset), 105, 0, false);
} }
} }
@ -1275,8 +1275,8 @@ void UI_DisplayMenu(void)
g_menu_cursor == MENU_MEM_NAME || g_menu_cursor == MENU_MEM_NAME ||
g_menu_cursor == MENU_MEM_DEL) && g_ask_for_confirmation) g_menu_cursor == MENU_MEM_DEL) && g_ask_for_confirmation)
{ // display confirmation { // display confirmation
strcpy(String, (g_ask_for_confirmation == 1) ? "SURE?" : "WAIT!"); strcpy(str, (g_ask_for_confirmation == 1) ? "SURE?" : "WAIT!");
UI_PrintString(String, sub_menu_x1, sub_menu_x2, 5, 8); UI_PrintString(str, sub_menu_x1, sub_menu_x2, 5, 8);
} }
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();

View File

@ -49,7 +49,7 @@ void UI_DisplayStatus(const bool test_display)
// POWER-SAVE indicator // POWER-SAVE indicator
if (g_current_function == FUNCTION_TRANSMIT) if (g_current_function == FUNCTION_TRANSMIT)
{ {
memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX)); memcpy(line + x, BITMAP_TX, sizeof(BITMAP_TX));
x1 = x + sizeof(BITMAP_TX); x1 = x + sizeof(BITMAP_TX);
} }
else else
@ -57,13 +57,13 @@ void UI_DisplayStatus(const bool test_display)
g_current_function == FUNCTION_MONITOR || g_current_function == FUNCTION_MONITOR ||
g_current_function == FUNCTION_NEW_RECEIVE) g_current_function == FUNCTION_NEW_RECEIVE)
{ {
memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX)); memcpy(line + x, BITMAP_RX, sizeof(BITMAP_RX));
x1 = x + sizeof(BITMAP_RX); x1 = x + sizeof(BITMAP_RX);
} }
else else
if (g_current_function == FUNCTION_POWER_SAVE || test_display) if (g_current_function == FUNCTION_POWER_SAVE || test_display)
{ {
memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE)); memcpy(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE));
x1 = x + sizeof(BITMAP_POWERSAVE); x1 = x + sizeof(BITMAP_POWERSAVE);
} }
x += sizeof(BITMAP_POWERSAVE); x += sizeof(BITMAP_POWERSAVE);
@ -72,7 +72,7 @@ void UI_DisplayStatus(const bool test_display)
// NOASS SCAN indicator // NOASS SCAN indicator
if (g_is_noaa_mode || test_display) if (g_is_noaa_mode || test_display)
{ {
memmove(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA)); memcpy(line + x, BITMAP_NOAA, sizeof(BITMAP_NOAA));
x1 = x + sizeof(BITMAP_NOAA); x1 = x + sizeof(BITMAP_NOAA);
} }
x += sizeof(BITMAP_NOAA); x += sizeof(BITMAP_NOAA);
@ -93,7 +93,7 @@ void UI_DisplayStatus(const bool test_display)
// FM indicator // FM indicator
if (g_fm_radio_mode || test_display) if (g_fm_radio_mode || test_display)
{ {
memmove(line + x, BITMAP_FM, sizeof(BITMAP_FM)); memcpy(line + x, BITMAP_FM, sizeof(BITMAP_FM));
x1 = x + sizeof(BITMAP_FM); x1 = x + sizeof(BITMAP_FM);
} }
else else
@ -125,7 +125,7 @@ void UI_DisplayStatus(const bool test_display)
// VOICE indicator // VOICE indicator
if (g_eeprom.voice_prompt != VOICE_PROMPT_OFF || test_display) if (g_eeprom.voice_prompt != VOICE_PROMPT_OFF || test_display)
{ {
memmove(line + x, BITMAP_VOICE_PROMPT, sizeof(BITMAP_VOICE_PROMPT)); memcpy(line + x, BITMAP_VOICE_PROMPT, sizeof(BITMAP_VOICE_PROMPT));
x1 = x + sizeof(BITMAP_VOICE_PROMPT); x1 = x + sizeof(BITMAP_VOICE_PROMPT);
} }
x += sizeof(BITMAP_VOICE_PROMPT); x += sizeof(BITMAP_VOICE_PROMPT);
@ -143,11 +143,11 @@ void UI_DisplayStatus(const bool test_display)
(g_current_function != FUNCTION_FOREGROUND && g_current_function != FUNCTION_POWER_SAVE) || (g_current_function != FUNCTION_FOREGROUND && g_current_function != FUNCTION_POWER_SAVE) ||
g_screen_to_display == DISPLAY_SEARCH) g_screen_to_display == DISPLAY_SEARCH)
{ {
memmove(line + x, BITMAP_TDR_HOLDING, sizeof(BITMAP_TDR_HOLDING)); memcpy(line + x, BITMAP_TDR_HOLDING, sizeof(BITMAP_TDR_HOLDING));
} }
else else
{ {
memmove(line + x, BITMAP_TDR_RUNNING, sizeof(BITMAP_TDR_RUNNING)); memcpy(line + x, BITMAP_TDR_RUNNING, sizeof(BITMAP_TDR_RUNNING));
} }
x1 = x + sizeof(BITMAP_TDR_RUNNING); x1 = x + sizeof(BITMAP_TDR_RUNNING);
} }
@ -155,7 +155,7 @@ void UI_DisplayStatus(const bool test_display)
if (g_current_function == FUNCTION_MONITOR) if (g_current_function == FUNCTION_MONITOR)
{ {
memmove(line + x, BITMAP_MONITOR, sizeof(BITMAP_MONITOR)); memcpy(line + x, BITMAP_MONITOR, sizeof(BITMAP_MONITOR));
x1 = x + sizeof(BITMAP_MONITOR); x1 = x + sizeof(BITMAP_MONITOR);
} }
x += sizeof(BITMAP_MONITOR); x += sizeof(BITMAP_MONITOR);
@ -163,7 +163,7 @@ void UI_DisplayStatus(const bool test_display)
// CROSS-VFO indicator // CROSS-VFO indicator
if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF || test_display) if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF || test_display)
{ {
memmove(line + x, BITMAP_XB, sizeof(BITMAP_XB)); memcpy(line + x, BITMAP_XB, sizeof(BITMAP_XB));
x1 = x + sizeof(BITMAP_XB); x1 = x + sizeof(BITMAP_XB);
} }
x += sizeof(BITMAP_XB); x += sizeof(BITMAP_XB);
@ -172,7 +172,7 @@ void UI_DisplayStatus(const bool test_display)
// VOX indicator // VOX indicator
if (g_eeprom.vox_switch || test_display) if (g_eeprom.vox_switch || test_display)
{ {
memmove(line + x, BITMAP_VOX, sizeof(BITMAP_VOX)); memcpy(line + x, BITMAP_VOX, sizeof(BITMAP_VOX));
x1 = x + sizeof(BITMAP_VOX); x1 = x + sizeof(BITMAP_VOX);
} }
x += sizeof(BITMAP_VOX); x += sizeof(BITMAP_VOX);
@ -182,7 +182,7 @@ void UI_DisplayStatus(const bool test_display)
// KEY-LOCK indicator // KEY-LOCK indicator
if (g_eeprom.key_lock || test_display) if (g_eeprom.key_lock || test_display)
{ {
memmove(line + x, BITMAP_KEYLOCK, sizeof(BITMAP_KEYLOCK)); memcpy(line + x, BITMAP_KEYLOCK, sizeof(BITMAP_KEYLOCK));
x += sizeof(BITMAP_KEYLOCK); x += sizeof(BITMAP_KEYLOCK);
x1 = x; x1 = x;
} }
@ -190,7 +190,7 @@ void UI_DisplayStatus(const bool test_display)
#endif #endif
if (g_fkey_pressed) if (g_fkey_pressed)
{ {
memmove(line + x, BITMAP_F_KEY, sizeof(BITMAP_F_KEY)); memcpy(line + x, BITMAP_F_KEY, sizeof(BITMAP_F_KEY));
x += sizeof(BITMAP_F_KEY); x += sizeof(BITMAP_F_KEY);
x1 = x; x1 = x;
} }
@ -236,7 +236,7 @@ void UI_DisplayStatus(const bool test_display)
// USB-C charge indicator // USB-C charge indicator
if (g_charging_with_type_c || test_display) if (g_charging_with_type_c || test_display)
memmove(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C)); memcpy(line + x, BITMAP_USB_C, sizeof(BITMAP_USB_C));
x += sizeof(BITMAP_USB_C); x += sizeof(BITMAP_USB_C);
// BATTERY LEVEL indicator // BATTERY LEVEL indicator

View File

@ -81,7 +81,7 @@ void UI_DisplayWelcome(void)
EEPROM_ReadBuffer(0x0EC0, str1, 16); EEPROM_ReadBuffer(0x0EC0, str1, 16);
} }
memmove(str2, Version_str, slen); memcpy(str2, Version_str, slen);
UI_PrintString(str0, 0, LCD_WIDTH, 0, 10); UI_PrintString(str0, 0, LCD_WIDTH, 0, 10);
UI_PrintString(str1, 0, LCD_WIDTH, 2, 10); UI_PrintString(str1, 0, LCD_WIDTH, 2, 10);