0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

added DTMF call/page compile option

This commit is contained in:
OneOfEleven
2023-12-08 14:04:02 +00:00
parent 0a9000a34c
commit 8084a92c39
21 changed files with 979 additions and 779 deletions

220
ui/main.c
View File

@ -233,10 +233,15 @@ bool UI_DisplayRSSIBar(const int rssi, const unsigned int glitch, const unsigned
return false; // display is in use
#endif
if (g_current_function == FUNCTION_TRANSMIT ||
g_current_display_screen != DISPLAY_MAIN ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return false; // display is in use
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_current_function == FUNCTION_TRANSMIT ||
g_current_display_screen != DISPLAY_MAIN)
{ // display is in use
return false;
}
// clear the line
memset(g_frame_buffer[line], 0, LCD_WIDTH);
@ -419,8 +424,10 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
g_reduced_service ||
g_current_display_screen != DISPLAY_MAIN ||
g_current_function == FUNCTION_POWER_SAVE ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
g_dtmf_input_mode ||
g_dtmf_input_mode ||
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
{ // don't draw the panadapter
return;
@ -517,19 +524,22 @@ void UI_DisplayCenterLine(void)
{
// const bool rx = (g_current_function == FUNCTION_RECEIVE && g_squelch_open) ? true : false;
const bool rx = (g_current_function == FUNCTION_RECEIVE) ? true : false;
#ifdef ENABLE_SINGLE_VFO_CHAN
const unsigned int line = (single_vfo >= 0 && !pan_enabled) ? 6 : 3;
#else
const unsigned int line = 3;
#endif
char str[22];
(void)rx;
(void)line;
(void)str;
if (g_center_line != CENTER_LINE_NONE ||
g_current_display_screen != DISPLAY_MAIN ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_center_line != CENTER_LINE_NONE || g_current_display_screen != DISPLAY_MAIN)
{
return;
}
@ -592,8 +602,14 @@ void UI_DisplayCenterLine(void)
const unsigned int len = strlen(g_dtmf_rx_live);
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_current_display_screen != DISPLAY_MAIN)
{
return;
}
g_center_line = CENTER_LINE_DTMF_DEC;
@ -607,8 +623,14 @@ void UI_DisplayCenterLine(void)
const unsigned int len = g_dtmf_rx_index;
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_current_display_screen != DISPLAY_MAIN)
{
return;
}
g_center_line = CENTER_LINE_DTMF_DEC;
@ -623,8 +645,14 @@ void UI_DisplayCenterLine(void)
else
if (g_charging_with_type_c)
{ // show the battery charge state
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_current_display_screen != DISPLAY_MAIN)
{
return;
}
g_center_line = CENTER_LINE_CHARGE_DATA;
@ -676,7 +704,7 @@ const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALA
unsigned int y = 0;
unsigned int x = 0;
#ifdef ENABLE_KILL_REVIVE
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
{
#ifdef ENABLE_SMALL_BOLD
@ -962,11 +990,13 @@ const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALA
//x += 7 * 7;
// DTMF decoding symbol
str[0] = 0;
if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable)
strcpy(str, "DTMF");
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 4), 0, y);
//x += 7 * 5;
#ifdef ENABLE_DTMF_CALLING
str[0] = 0;
if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable)
strcpy(str, "DTMF");
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 4), 0, y);
//x += 7 * 5;
#endif
}
UI_DisplayCenterLine();
@ -1066,73 +1096,95 @@ void UI_DisplayMain(void)
if (current_vfo_num != vfo_num)
{
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE || g_dtmf_is_tx || g_dtmf_input_mode)
{ // show DTMF stuff
char contact[17];
if (!g_dtmf_input_mode)
{
memset(contact, 0, sizeof(contact));
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT)
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE || g_dtmf_is_tx || g_dtmf_input_mode)
{ // show DTMF stuff
char contact[17];
if (!g_dtmf_input_mode)
{
strcpy(str, (g_dtmf_state == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT RESP" : "CALL OUT");
memset(contact, 0, sizeof(contact));
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT)
{
strcpy(str, (g_dtmf_state == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT RESP" : "CALL OUT");
}
else
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);
contact[8] = 0;
sprintf(str, "FROM %s", found ? contact : g_dtmf_caller);
}
else
if (g_dtmf_is_tx)
{
strcpy(str, (g_dtmf_state == DTMF_STATE_TX_SUCC) ? "DTMF TX SUCC" : "DTMF TX");
}
}
else
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);
contact[8] = 0;
sprintf(str, "FROM %s", found ? contact : g_dtmf_caller);
sprintf(str, "DTMF entry");
}
str[16] = 0;
UI_PrintString(str, 2, 0, 0 + (vfo_num * 3), 8);
memset(str, 0, sizeof(str));
if (!g_dtmf_input_mode)
{
memset(contact, 0, sizeof(contact));
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT)
{
const bool found = DTMF_FindContact(g_dtmf_string, contact);
contact[15] = 0;
sprintf(str, ">%s", found ? contact : g_dtmf_string);
}
else
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);
contact[15] = 0;
sprintf(str, ">%s", found ? contact : g_dtmf_callee);
}
else
if (g_dtmf_is_tx)
{
sprintf(str, ">%s", g_dtmf_string);
}
}
else
if (g_dtmf_is_tx)
{
strcpy(str, (g_dtmf_state == DTMF_STATE_TX_SUCC) ? "DTMF TX SUCC" : "DTMF TX");
sprintf(str, ">%s", g_dtmf_input_box);
}
str[16] = 0;
UI_PrintString(str, 2, 0, 2 + (vfo_num * 3), 8);
pan_enabled = false;
g_center_line = CENTER_LINE_IN_USE;
continue;
}
else
{
sprintf(str, "DTMF entry");
#else
if (g_dtmf_is_tx || g_dtmf_input_mode)
{ // show DTMF stuff
str[0] = 0;
if (g_dtmf_input_mode)
sprintf(str, "DTMF entry");
UI_PrintString(str, 2, 0, 0 + (vfo_num * 3), 8);
str[0] = 0;
if (g_dtmf_input_mode)
sprintf(str, ">%s", g_dtmf_input_box);
str[16] = 0;
UI_PrintString(str, 2, 0, 2 + (vfo_num * 3), 8);
pan_enabled = false;
g_center_line = CENTER_LINE_IN_USE;
continue;
}
str[16] = 0;
UI_PrintString(str, 2, 0, 0 + (vfo_num * 3), 8);
memset(str, 0, sizeof(str));
if (!g_dtmf_input_mode)
{
memset(contact, 0, sizeof(contact));
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT)
{
const bool found = DTMF_FindContact(g_dtmf_string, contact);
contact[15] = 0;
sprintf(str, ">%s", found ? contact : g_dtmf_string);
}
else
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);
contact[15] = 0;
sprintf(str, ">%s", found ? contact : g_dtmf_callee);
}
else
if (g_dtmf_is_tx)
{
sprintf(str, ">%s", g_dtmf_string);
}
}
else
{
sprintf(str, ">%s", g_dtmf_input_box);
}
str[16] = 0;
UI_PrintString(str, 2, 0, 2 + (vfo_num * 3), 8);
pan_enabled = false;
g_center_line = CENTER_LINE_IN_USE;
continue;
}
#endif
}
if (single_vfo < 0)
@ -1513,13 +1565,15 @@ void UI_DisplayMain(void)
UI_PrintStringSmall(str, 70, 0, line + 2);
// show the DTMF decoding symbol
#ifdef ENABLE_KILL_REVIVE
if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
UI_PrintStringSmall("DTMF", 78, 0, line + 2);
#else
if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable)
UI_PrintStringSmall("DTMF", 78, 0, line + 2);
//UI_PrintStringSmallest("DTMF", 78, (line + 2) * 8, false, true);
#ifdef ENABLE_DTMF_CALLING
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
UI_PrintStringSmall("DTMF", 78, 0, line + 2);
#else
if (g_vfo_info[vfo_num].channel.dtmf_decoding_enable)
UI_PrintStringSmall("DTMF", 78, 0, line + 2);
//UI_PrintStringSmallest("DTMF", 78, (line + 2) * 8, false, true);
#endif
#endif
// show the audio scramble symbol

175
ui/menu.c
View File

@ -109,7 +109,9 @@ const t_menu_item g_menu_list[] =
#ifdef ENABLE_ALARM
{"SOS AL", VOICE_ID_INVALID, MENU_ALARM_MODE }, // was "ALMODE"
#endif
#ifdef ENABLE_DTMF_CALLING
{"ANI ID", VOICE_ID_ANI_CODE, MENU_ANI_ID },
#endif
{"UpCODE", VOICE_ID_INVALID, MENU_UP_CODE },
{"DnCODE", VOICE_ID_INVALID, MENU_DN_CODE }, // was "DWCODE"
#ifdef ENABLE_MDC1200
@ -118,10 +120,12 @@ const t_menu_item g_menu_list[] =
#endif
{"PTT ID", VOICE_ID_INVALID, MENU_PTT_ID },
{"D ST", VOICE_ID_INVALID, MENU_DTMF_ST },
#ifdef ENABLE_DTMF_CALLING
{"D RSP", VOICE_ID_INVALID, MENU_DTMF_RSP },
{"D HOLD", VOICE_ID_INVALID, MENU_DTMF_HOLD },
{"D DCD", VOICE_ID_INVALID, MENU_DTMF_DCD },
{"D LIST", VOICE_ID_INVALID, MENU_DTMF_LIST },
#endif
#ifdef ENABLE_DTMF_LIVE_DECODER
{"D LIVE", VOICE_ID_INVALID, MENU_DTMF_LIVE_DEC }, // live DTMF decoder
#endif
@ -298,13 +302,15 @@ const char g_sub_menu_mem_disp[4][12] =
};
#endif
const char g_sub_menu_dtmf_rsp[4][9] =
{
"NONE",
"RING",
"REPLY",
"RNG RPLY"
};
#ifdef ENABLE_DTMF_CALLING
const char g_sub_menu_dtmf_rsp[4][9] =
{
"NONE",
"RING",
"REPLY",
"RNG RPLY"
};
#endif
const char g_sub_menu_ptt_id[5][16] =
{
@ -836,14 +842,26 @@ void UI_DisplayMenu(void)
strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
break;
#ifdef ENABLE_DTMF_LIVE_DECODER
#if defined(ENABLE_DTMF_LIVE_DECODER) && defined(ENABLE_DTMF_CALLING)
case MENU_DTMF_DCD:
case MENU_DTMF_LIVE_DEC:
strcpy(str, "DTMF\nDECODE\n");
strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
channel_setting = true;
break;
#elif defined(ENABLE_DTMF_CALLING)
case MENU_DTMF_DCD:
strcpy(str, "DTMF\nDECODE\n");
strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
channel_setting = true;
break;
#elif defined(ENABLE_DTMF_LIVE_DECODER)
case MENU_DTMF_LIVE_DEC:
strcpy(str, "DTMF\nDECODE\n");
strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
channel_setting = true;
break;
#endif
case MENU_DTMF_DCD:
strcpy(str, "DTMF\nDECODE\n");
strcat(str, g_sub_menu_off_on[g_sub_menu_selection]);
channel_setting = true;
break;
case MENU_STE:
strcpy(str, "SUB TAIL\nELIMIN\n");
@ -1028,10 +1046,12 @@ void UI_DisplayMenu(void)
break;
#endif
case MENU_ANI_ID:
strcpy(str, "DTMF ID\n");
strcat(str, g_eeprom.config.setting.dtmf.ani_id);
break;
#ifdef ENABLE_DTMF_CALLING
case MENU_ANI_ID:
strcpy(str, "DTMF ID\n");
strcat(str, g_eeprom.config.setting.dtmf.ani_id);
break;
#endif
case MENU_UP_CODE:
strcpy(str, "DTMF BOT\n");
@ -1045,39 +1065,66 @@ void UI_DisplayMenu(void)
channel_setting = true;
break;
case MENU_DTMF_RSP:
strcpy(str, "DTMF\nRESP\n");
strcat(str, g_sub_menu_dtmf_rsp[g_sub_menu_selection]);
case MENU_PTT_ID:
strcpy(str, g_sub_menu_ptt_id[g_sub_menu_selection]);
channel_setting = true;
break;
case MENU_DTMF_HOLD:
// only allow 5, 10, 20, 30, 40, 50 or "STAY ON SCREEN" (60)
switch (g_sub_menu_selection)
#ifdef ENABLE_DTMF_CALLING
case MENU_DTMF_RSP:
strcpy(str, "DTMF\nRESP\n");
strcat(str, g_sub_menu_dtmf_rsp[g_sub_menu_selection]);
channel_setting = true;
break;
case MENU_DTMF_HOLD:
// only allow 5, 10, 20, 30, 40, 50 or "STAY ON SCREEN" (60)
switch (g_sub_menu_selection)
{
case 4: g_sub_menu_selection = 60; break;
case 6: g_sub_menu_selection = 10; break;
case 9: g_sub_menu_selection = 5; break;
case 11: g_sub_menu_selection = 20; break;
case 19: g_sub_menu_selection = 10; break;
case 21: g_sub_menu_selection = 30; break;
case 29: g_sub_menu_selection = 20; break;
case 31: g_sub_menu_selection = 40; break;
case 39: g_sub_menu_selection = 30; break;
case 41: g_sub_menu_selection = 50; break;
case 49: g_sub_menu_selection = 40; break;
case 51: g_sub_menu_selection = 60; break;
case 59: g_sub_menu_selection = 50; break;
case 61: g_sub_menu_selection = 5; break;
}
strcpy(str, "DTMF MSG\n");
if (g_sub_menu_selection < DTMF_HOLD_MAX)
sprintf(str + strlen(str), "%d sec", g_sub_menu_selection);
else
strcat(str, "STAY ON\nSCRN"); // 60
break;
case MENU_DTMF_LIST:
{
case 4: g_sub_menu_selection = 60; break;
case 6: g_sub_menu_selection = 10; break;
case 9: g_sub_menu_selection = 5; break;
case 11: g_sub_menu_selection = 20; break;
case 19: g_sub_menu_selection = 10; break;
case 21: g_sub_menu_selection = 30; break;
case 29: g_sub_menu_selection = 20; break;
case 31: g_sub_menu_selection = 40; break;
case 39: g_sub_menu_selection = 30; break;
case 41: g_sub_menu_selection = 50; break;
case 49: g_sub_menu_selection = 40; break;
case 51: g_sub_menu_selection = 60; break;
case 59: g_sub_menu_selection = 50; break;
case 61: g_sub_menu_selection = 5; break;
char Contact[17];
g_dtmf_is_contact_valid = DTMF_GetContact((int)g_sub_menu_selection - 1, Contact);
strcpy(str, "DTMF\n");
if (!g_dtmf_is_contact_valid)
{
strcat(str, "NULL");
}
else
{
memcpy(str + strlen(str), Contact, 8);
Contact[11] = 0;
memcpy(&g_dtmf_id, Contact + 8, sizeof(g_dtmf_id));
sprintf(str + strlen(str), "\nID:%s", Contact + 8);
}
break;
}
strcpy(str, "DTMF MSG\n");
if (g_sub_menu_selection < DTMF_HOLD_MAX)
sprintf(str + strlen(str), "%d sec", g_sub_menu_selection);
else
strcat(str, "STAY ON\nSCRN"); // 60
break;
#endif
#ifdef ENABLE_DTMF_TIMING_SETTINGS
case MENU_DTMF_PRE:
@ -1120,34 +1167,10 @@ void UI_DisplayMenu(void)
break;
#endif
case MENU_PTT_ID:
strcpy(str, g_sub_menu_ptt_id[g_sub_menu_selection]);
channel_setting = true;
break;
case MENU_BAT_TXT:
strcpy(str, g_sub_menu_bat_text[g_sub_menu_selection]);
break;
case MENU_DTMF_LIST:
{
char Contact[17];
g_dtmf_is_contact_valid = DTMF_GetContact((int)g_sub_menu_selection - 1, Contact);
strcpy(str, "DTMF\n");
if (!g_dtmf_is_contact_valid)
{
strcat(str, "NULL");
}
else
{
memcpy(str + strlen(str), Contact, 8);
Contact[11] = 0;
memcpy(&g_dtmf_id, Contact + 8, sizeof(g_dtmf_id));
sprintf(str + strlen(str), "\nID:%s", Contact + 8);
}
break;
}
case MENU_PON_MSG:
strcpy(str, g_sub_menu_pwr_on_msg[g_sub_menu_selection]);
break;
@ -1421,17 +1444,23 @@ void UI_DisplayMenu(void)
if (strlen(g_eeprom.config.setting.dtmf.key_down_code) > 8)
UI_PrintString(g_eeprom.config.setting.dtmf.key_down_code + 8, sub_menu_x1, sub_menu_x2, 4, 8);
if (g_menu_cursor == MENU_RX_CTCSS ||
if (
#ifdef ENABLE_DTMF_CALLING
g_menu_cursor == MENU_DTMF_LIST ||
#endif
g_menu_cursor == MENU_RX_CTCSS ||
g_menu_cursor == MENU_TX_CTCSS ||
g_menu_cursor == MENU_RX_CDCSS ||
g_menu_cursor == MENU_TX_CDCSS ||
g_menu_cursor == MENU_DTMF_LIST)
g_menu_cursor == MENU_TX_CDCSS)
{
if (g_in_sub_menu)
{
unsigned int Offset;
#ifdef ENABLE_DTMF_CALLING
const unsigned int Offset = (g_menu_cursor == MENU_DTMF_LIST) ? 2 : 3;
#else
const unsigned int Offset = 3;
#endif
NUMBER_ToDigits(g_sub_menu_selection, str);
Offset = (g_menu_cursor == MENU_DTMF_LIST) ? 2 : 3;
UI_Displaysmall_digits(Offset, str + (8 - Offset), 105, 0, false);
}
}

View File

@ -95,14 +95,18 @@ enum
MENU_S_LIST,
MENU_SLIST1,
MENU_SLIST2,
#ifdef ENABLE_DTMF_CALLING
MENU_ANI_ID,
#endif
MENU_UP_CODE,
MENU_DN_CODE,
MENU_DTMF_ST,
#ifdef ENABLE_DTMF_CALLING
MENU_DTMF_HOLD,
MENU_DTMF_LIST,
MENU_DTMF_RSP,
MENU_DTMF_DCD,
#endif
#ifdef ENABLE_DTMF_LIVE_DECODER
MENU_DTMF_LIVE_DEC,
#endif
@ -200,7 +204,9 @@ extern const char g_sub_menu_mem_disp[4][12];
#ifdef ENABLE_ALARM
extern const char g_sub_menu_alarm_mode[2][5];
#endif
extern const char g_sub_menu_dtmf_rsp[4][9];
#ifdef ENABLE_DTMF_CALLING
extern const char g_sub_menu_dtmf_rsp[4][9];
#endif
extern const char g_sub_menu_ptt_id[5][16];
#ifdef ENABLE_MDC1200
extern const char g_sub_menu_mdc1200_mode[4][5];

View File

@ -80,7 +80,7 @@ void UI_DisplayStatus(const bool test_display)
}
#endif
#ifdef ENABLE_KILL_REVIVE
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
{
memset(line + x, 0xFF, 10);
@ -143,7 +143,9 @@ void UI_DisplayStatus(const bool test_display)
#endif
if (g_dual_watch_tick_10ms > dual_watch_delay_toggle_10ms ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
(g_current_function != FUNCTION_FOREGROUND && g_current_function != FUNCTION_POWER_SAVE) ||