0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-27 13:51:25 +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

View File

@ -27,7 +27,7 @@ ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_MUTE_RADIO_FOR_VOICE := 0
# Tx on Voice 1.0 kB
ENABLE_VOX := 0
ENABLE_VOX := 1
ENABLE_VOX_MORE_SENSITIVE := 1
# Tx Alarm 600 B
ENABLE_ALARM := 0
@ -40,11 +40,15 @@ ENABLE_MDC1200_SIDE_BEEP := 1
ENABLE_PWRON_PASSWORD := 0
ENABLE_RESET_AES_KEY := 0
ENABLE_BIG_FREQ := 0
ENABLE_DTMF_LIVE_DECODER := 0
ENABLE_DTMF_CALLING := 0
ENABLE_DTMF_LIVE_DECODER := 1
ENABLE_DTMF_TIMING_SETTINGS := 0
ENABLE_DTMF_CALL_FLASH_LIGHT := 0
# Kill and Revive 400 B
ENABLE_DTMF_KILL_REVIVE := 0
ENABLE_SHOW_FREQ_IN_CHAN := 1
# smaa bold 580 B
ENABLE_SMALL_BOLD := 0
ENABLE_SMALL_BOLD := 1
# smallest font 2 kB
ENABLE_SMALLEST_FONT := 0
# trim trailing 44 B
@ -60,19 +64,16 @@ ENABLE_TX_POWER_FIX := 1
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_CONTRAST := 0
ENABLE_BOOT_BEEPS := 0
ENABLE_DTMF_CALL_FLASH_LIGHT := 0
ENABLE_FLASH_LIGHT_SOS_TONE := 0
ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 0
ENABLE_FREQ_SEARCH_LNA := 0
ENABLE_FREQ_SEARCH_LNA := 1
ENABLE_FREQ_SEARCH_TIMEOUT := 0
ENABLE_CODE_SEARCH_TIMEOUT := 0
# scan ignore list 740 B
ENABLE_SCAN_IGNORE_LIST := 0
ENABLE_SCAN_IGNORE_LIST := 1
# scan ranges 400 B
ENABLE_SCAN_RANGES := 0
# Kill and Revive 400 B
ENABLE_KILL_REVIVE := 0
ENABLE_SCAN_RANGES := 1
# AM Fix 800 B
ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 0
@ -334,6 +335,9 @@ endif
ifeq ($(ENABLE_BIG_FREQ),1)
CFLAGS += -DENABLE_BIG_FREQ
endif
ifeq ($(ENABLE_DTMF_CALLING),1)
CFLAGS += -DENABLE_DTMF_CALLING
endif
ifeq ($(ENABLE_DTMF_LIVE_DECODER),1)
CFLAGS += -DENABLE_DTMF_LIVE_DECODER
endif
@ -439,8 +443,8 @@ endif
ifeq ($(ENABLE_SCAN_RANGES),1)
CFLAGS += -DENABLE_SCAN_RANGES
endif
ifeq ($(ENABLE_KILL_REVIVE),1)
CFLAGS += -DENABLE_KILL_REVIVE
ifeq ($(ENABLE_DTMF_KILL_REVIVE),1)
CFLAGS += -DENABLE_DTMF_KILL_REVIVE
endif
ifeq ($(ENABLE_FREQ_SEARCH_LNA),1)
CFLAGS += -DENABLE_FREQ_SEARCH_LNA

View File

@ -64,8 +64,10 @@ ENABLE_MDC1200_SIDE_BEEP := 1 enable short side tone/beep when MDC
ENABLE_PWRON_PASSWORD := 0 include power-on password code
ENABLE_RESET_AES_KEY := 1 '1' = reset/clear the AES key stored in the eeprom (only if it's set)
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
ENABLE_DTMF_CALLING := 0 enable the DTMF calling/paging features
ENABLE_DTMF_LIVE_DECODER := 0 enable the live DTMF display/decoder .. adds a menu option
ENABLE_DTMF_TIMING_SETTINGS := 0 enable the DTMF timing settings in the menu
ENABLE_DTMF_CALL_FLASH_LIGHT := 0 flash the flash light LED when a DTMF call is received
ENABLE_SHOW_FREQ_IN_CHAN := 0 indicate if frequency found in a channel
ENABLE_SMALL_BOLD := 0 bold channel name/no. (when name + freq channel display mode)
ENABLE_TRIM_TRAILING_ZEROS := 0 trim away any trailing zeros on frequencies
@ -79,7 +81,6 @@ ENABLE_TX_POWER_FIX := 1 fix the TX output power, L ~ 10mW, M
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0 standard CTCSS tail phase shift rather than QS's own 55Hz tone method
ENABLE_CONTRAST := 0 add contrast menu
ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up
ENABLE_DTMF_CALL_FLASH_LIGHT := 0 flash the flash light LED when a DTMF call is received
ENABLE_FLASH_LIGHT_SOS_TONE := 0 also do SOS in morse
ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge
ENABLE_REVERSE_BAT_SYMBOL := 0 mirror the battery symbol on the status bar (+ pole on the right)
@ -88,7 +89,7 @@ ENABLE_FREQ_SEARCH_TIMEOUT := 0 timeout if FREQ not found when using
ENABLE_CODE_SEARCH_TIMEOUT := 0 timeout if CTCSS/CDCSS not found when using F+* search function
ENABLE_SCAN_IGNORE_LIST := 0 ignore selected frequencies when scanning - add freqs to list with short */scan button when freq scanning, remove freq from list with long press MENU when not scanning
ENABLE_SCAN_RANGES := 0 adds menu option to auto select frequency scan range/step depending on your initial frequency
ENABLE_KILL_REVIVE := 0 include kill and revive code
ENABLE_DTMF_KILL_REVIVE := 0 include kill and revive code
ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to help prevent AM demodulator saturation, ignore the on-screen RSSI level (for now)
ENABLE_AM_FIX_SHOW_DATA := 0 show debug data for the AM fix (still tweaking it)
ENABLE_SQUELCH_MORE_SENSITIVE := 1 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves

View File

@ -207,7 +207,9 @@ void ACTION_Scan(bool bRestart)
g_monitor_enabled = false;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
DTMF_clear_RX();
#ifdef ENABLE_DTMF_CALLING
DTMF_clear_RX();
#endif
#ifdef ENABLE_DTMF_LIVE_DECODER
g_dtmf_rx_live_timeout = 0;

182
app/app.c
View File

@ -198,8 +198,10 @@ static void APP_process_new_receive(void)
if (!g_squelch_open && !g_monitor_enabled)
{ // squelch is closed
if (g_dtmf_rx_index > 0)
DTMF_clear_RX();
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_rx_index > 0)
DTMF_clear_RX();
#endif
if (g_current_function != FUNCTION_FOREGROUND)
{
@ -250,10 +252,11 @@ static void APP_process_new_receive(void)
return;
}
#ifdef ENABLE_DTMF_CALLING
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
{ // not scanning
#ifdef ENABLE_KILL_REVIVE
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_rx_vfo->channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
#else
if (g_rx_vfo->channel.dtmf_decoding_enable)
@ -276,6 +279,7 @@ static void APP_process_new_receive(void)
}
}
}
#endif
APP_start_listening();
}
@ -487,10 +491,12 @@ bool APP_start_listening(void)
const unsigned int chan = g_rx_vfo_num;
// const unsigned int chan = g_rx_vfo->channel_save;
#ifdef ENABLE_KILL_REVIVE
#ifdef ENABLE_DTMF_CALLING
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
return false;
#endif
#endif
if (g_squelch_open)
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // green LED on
@ -882,8 +888,10 @@ static bool APP_toggle_dual_watch_vfo(void)
return false;
if (g_ptt_is_pressed)
return false;
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return false;
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return false;
#endif
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
return false;
@ -1024,24 +1032,26 @@ void APP_process_radio_interrupts(void)
}
#endif
#ifdef ENABLE_KILL_REVIVE
if (g_rx_vfo->channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
#else
if (g_rx_vfo->channel.dtmf_decoding_enable)
#endif
{
if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1))
{ // make room
memmove(&g_dtmf_rx[0], &g_dtmf_rx[1], sizeof(g_dtmf_rx) - 1);
g_dtmf_rx_index--;
#ifdef ENABLE_DTMF_CALLING
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_rx_vfo->channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled)
#else
if (g_rx_vfo->channel.dtmf_decoding_enable)
#endif
{
if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1))
{ // make room
memmove(&g_dtmf_rx[0], &g_dtmf_rx[1], sizeof(g_dtmf_rx) - 1);
g_dtmf_rx_index--;
}
g_dtmf_rx[g_dtmf_rx_index++] = c;
g_dtmf_rx[g_dtmf_rx_index] = 0;
g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it
g_dtmf_rx_pending = true;
DTMF_HandleRequest();
}
g_dtmf_rx[g_dtmf_rx_index++] = c;
g_dtmf_rx[g_dtmf_rx_index] = 0;
g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it
g_dtmf_rx_pending = true;
DTMF_HandleRequest();
}
#endif
}
}
@ -1272,9 +1282,11 @@ void APP_end_tx(void)
g_update_status = true;
#ifdef ENABLE_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
return;
#ifdef ENABLE_DTMF_CALLING
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
return;
#endif
#endif
if (!g_eeprom.config.setting.tx_enable)
@ -1319,9 +1331,11 @@ void APP_process_keys(void)
key_code_t key;
#ifdef ENABLE_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
return;
#ifdef ENABLE_DTMF_CALLING
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
return;
#endif
#endif
// *****************
@ -1345,7 +1359,7 @@ void APP_process_keys(void)
if (g_current_display_screen != DISPLAY_AIRCOPY)
#endif
{
#ifdef ENABLE_KILL_REVIVE
#if defined(ENABLE_DTMF_CALLING) && defined(ENABLE_DTMF_KILL_REVIVE)
if (!g_eeprom.config.setting.radio_disabled)
#endif
{
@ -1929,7 +1943,9 @@ void APP_process_power_save(void)
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_current_display_screen != DISPLAY_MAIN ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_flash_light_state == FLASHLIGHT_SOS)
{
power_save = false;
@ -2129,9 +2145,11 @@ void APP_time_slice_500ms(void)
if (--g_menu_tick_10ms == 0)
exit_menu = (g_current_display_screen == DISPLAY_MENU); // exit menu mode
if (g_dtmf_rx_timeout > 0)
if (--g_dtmf_rx_timeout == 0)
DTMF_clear_RX();
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_rx_timeout > 0)
if (--g_dtmf_rx_timeout == 0)
DTMF_clear_RX();
#endif
#ifdef ENABLE_FMRADIO
if (g_fm_radio_tick_500ms > 0)
@ -2350,48 +2368,50 @@ void APP_time_slice_500ms(void)
return;
#endif
if (g_current_function != FUNCTION_TRANSMIT)
{
if (g_dtmf_decode_ring_tick_500ms > 0)
{ // make "ring-ring" sound
g_dtmf_decode_ring_tick_500ms--;
#ifdef ENABLE_DTMF_CALL_FLASH_LIGHT
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); // light on
#endif
AUDIO_PlayBeep(BEEP_880HZ_200MS);
#ifdef ENABLE_DTMF_CALL_FLASH_LIGHT
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); // light off
#endif
}
}
else
g_dtmf_decode_ring_tick_500ms = 0;
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE &&
g_current_function != FUNCTION_TRANSMIT &&
g_current_function != FUNCTION_RECEIVE)
{
if (g_dtmf_auto_reset_time_500ms > 0)
#ifdef ENABLE_DTMF_CALLING
if (g_current_function != FUNCTION_TRANSMIT)
{
if (--g_dtmf_auto_reset_time_500ms == 0)
{
if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED && g_eeprom.config.setting.dtmf.auto_reset_time >= DTMF_HOLD_MAX)
g_dtmf_call_state = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed
else
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
if (g_dtmf_decode_ring_tick_500ms > 0)
{ // make "ring-ring" sound
g_dtmf_decode_ring_tick_500ms--;
#ifdef ENABLE_DTMF_CALL_FLASH_LIGHT
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); // light on
#endif
AUDIO_PlayBeep(BEEP_880HZ_200MS);
#ifdef ENABLE_DTMF_CALL_FLASH_LIGHT
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); // light off
#endif
}
}
else
g_dtmf_decode_ring_tick_500ms = 0;
// if (g_dtmf_call_state != DTMF_CALL_STATE_RECEIVED_STAY)
// {
// g_dtmf_call_state = DTMF_CALL_STATE_NONE;
// g_update_display = true;
// }
}
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE &&
g_current_function != FUNCTION_TRANSMIT &&
g_current_function != FUNCTION_RECEIVE)
{
if (g_dtmf_auto_reset_time_500ms > 0)
{
if (--g_dtmf_auto_reset_time_500ms == 0)
{
if (g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED && g_eeprom.config.setting.dtmf.auto_reset_time >= DTMF_HOLD_MAX)
g_dtmf_call_state = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed
else
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
}
}
// if (g_dtmf_call_state != DTMF_CALL_STATE_RECEIVED_STAY)
// {
// g_dtmf_call_state = DTMF_CALL_STATE_NONE;
// g_update_display = true;
// }
}
#endif
if (g_dtmf_is_tx && g_dtmf_tx_stop_tick_500ms > 0)
{
@ -2636,7 +2656,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
#ifdef ENABLE_AIRCOPY
if (g_current_display_screen == DISPLAY_AIRCOPY)
{
AIRCOPY_process_key(key, key_pressed, key_held);
AIRCOPY_process_key(Key, key_pressed, key_held);
return;
}
#endif
@ -2755,8 +2775,10 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
g_menu_tick_10ms = menu_timeout_500ms;
// cancel the ringing
if (key_pressed && g_dtmf_decode_ring_tick_500ms > 0)
g_dtmf_decode_ring_tick_500ms = 0;
#ifdef ENABLE_DTMF_CALLING
if (key_pressed && g_dtmf_decode_ring_tick_500ms > 0)
g_dtmf_decode_ring_tick_500ms = 0;
#endif
// ********************
@ -3063,10 +3085,12 @@ Skip:
// g_tx_vfo->freq_in_channel = SETTINGS_find_channel(frequency);
g_dtmf_auto_reset_time_500ms = 0;
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_dtmf_tx_stop_tick_500ms = 0;
g_dtmf_is_tx = false;
#ifdef ENABLE_DTMF_CALLING
g_dtmf_auto_reset_time_500ms = 0;
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
#endif
g_dtmf_tx_stop_tick_500ms = 0;
g_dtmf_is_tx = false;
g_vfo_rssi_bar_level[0] = 0;
g_vfo_rssi_bar_level[1] = 0;

View File

@ -41,38 +41,43 @@ uint8_t g_dtmf_input_box_index;
bool g_dtmf_input_mode;
uint8_t g_dtmf_prev_index;
char g_dtmf_rx[17];
uint8_t g_dtmf_rx_index;
uint8_t g_dtmf_rx_timeout;
bool g_dtmf_rx_pending;
#ifdef ENABLE_DTMF_LIVE_DECODER
char g_dtmf_rx_live[20];
uint8_t g_dtmf_rx_live_timeout;
#endif
bool g_dtmf_is_contact_valid;
char g_dtmf_id[4];
char g_dtmf_caller[4];
char g_dtmf_callee[4];
dtmf_state_t g_dtmf_state;
uint8_t g_dtmf_decode_ring_tick_500ms;
uint8_t g_dtmf_chosen_contact;
uint8_t g_dtmf_auto_reset_time_500ms;
dtmf_call_state_t g_dtmf_call_state;
dtmf_reply_state_t g_dtmf_reply_state;
dtmf_call_mode_t g_dtmf_call_mode;
bool g_dtmf_is_tx;
uint8_t g_dtmf_tx_stop_tick_500ms;
bool g_dtmf_IsGroupCall;
#ifdef ENABLE_DTMF_CALLING
char g_dtmf_rx[17];
uint8_t g_dtmf_rx_index;
uint8_t g_dtmf_rx_timeout;
bool g_dtmf_rx_pending;
bool g_dtmf_is_contact_valid;
char g_dtmf_id[4];
char g_dtmf_caller[4];
char g_dtmf_callee[4];
dtmf_state_t g_dtmf_state;
uint8_t g_dtmf_decode_ring_tick_500ms;
uint8_t g_dtmf_chosen_contact;
uint8_t g_dtmf_auto_reset_time_500ms;
dtmf_call_state_t g_dtmf_call_state;
dtmf_call_mode_t g_dtmf_call_mode;
bool g_dtmf_IsGroupCall;
#endif
void DTMF_clear_RX(void)
{
g_dtmf_rx_timeout = 0;
g_dtmf_rx_index = 0;
g_dtmf_rx_pending = false;
memset(g_dtmf_rx, 0, sizeof(g_dtmf_rx));
}
dtmf_reply_state_t g_dtmf_reply_state;
bool g_dtmf_is_tx;
uint8_t g_dtmf_tx_stop_tick_500ms;
#ifdef ENABLE_DTMF_CALLING
void DTMF_clear_RX(void)
{
g_dtmf_rx_timeout = 0;
g_dtmf_rx_index = 0;
g_dtmf_rx_pending = false;
memset(g_dtmf_rx, 0, sizeof(g_dtmf_rx));
}
#endif
bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
{
@ -96,44 +101,46 @@ bool DTMF_ValidateCodes(char *pCode, const unsigned int size)
return true;
}
bool DTMF_GetContact(const int Index, char *pContact)
{
int i = -1;
if (Index >= 0 && Index < (int)ARRAY_SIZE(g_eeprom.config.dtmf_contact))
#ifdef ENABLE_DTMF_CALLING
bool DTMF_GetContact(const int Index, char *pContact)
{
memcpy(pContact, &g_eeprom.config.dtmf_contact[Index], 16);
// EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
i = (int)pContact[0] - ' ';
}
return (i < 0 || i >= 95) ? false : true;
}
bool DTMF_FindContact(const char *pContact, char *pResult)
{
char Contact[16];
unsigned int i;
for (i = 0; i < MAX_DTMF_CONTACTS; i++)
{
unsigned int j;
if (!DTMF_GetContact(i, Contact))
return false;
for (j = 0; j < 3; j++)
if (pContact[j] != Contact[j + 8])
break;
if (j == 3)
int i = -1;
if (Index >= 0 && Index < (int)ARRAY_SIZE(g_eeprom.config.dtmf_contact))
{
memcpy(pResult, Contact, 8);
pResult[8] = 0;
return true;
memcpy(pContact, &g_eeprom.config.dtmf_contact[Index], 16);
// EEPROM_ReadBuffer(0x1C00 + (Index * 16), pContact, 16);
i = (int)pContact[0] - ' ';
}
return (i < 0 || i >= 95) ? false : true;
}
return false;
}
bool DTMF_FindContact(const char *pContact, char *pResult)
{
char Contact[16];
unsigned int i;
for (i = 0; i < MAX_DTMF_CONTACTS; i++)
{
unsigned int j;
if (!DTMF_GetContact(i, Contact))
return false;
for (j = 0; j < 3; j++)
if (pContact[j] != Contact[j + 8])
break;
if (j == 3)
{
memcpy(pResult, Contact, 8);
pResult[8] = 0;
return true;
}
}
return false;
}
#endif
char DTMF_GetCharacter(const unsigned int code)
{
@ -159,31 +166,33 @@ char DTMF_GetCharacter(const unsigned int code)
}
}
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup)
{
unsigned int i;
for (i = 0; i < size; i++)
#ifdef ENABLE_DTMF_CALLING
bool DTMF_CompareMessage(const char *pMsg, const char *pTemplate, const unsigned int size, const bool bCheckGroup)
{
if (pMsg[i] != pTemplate[i])
unsigned int i;
for (i = 0; i < size; i++)
{
if (!bCheckGroup || pMsg[i] != g_eeprom.config.setting.dtmf.group_call_code)
return false;
g_dtmf_IsGroupCall = true;
if (pMsg[i] != pTemplate[i])
{
if (!bCheckGroup || pMsg[i] != g_eeprom.config.setting.dtmf.group_call_code)
return false;
g_dtmf_IsGroupCall = true;
}
}
return true;
}
return true;
}
dtmf_call_mode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
{
unsigned int i;
for (i = 0; i < size; i++)
if (pMsg[i] == g_eeprom.config.setting.dtmf.group_call_code)
break;
return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
}
dtmf_call_mode_t DTMF_CheckGroupCall(const char *pMsg, const unsigned int size)
{
unsigned int i;
for (i = 0; i < size; i++)
if (pMsg[i] == g_eeprom.config.setting.dtmf.group_call_code)
break;
return (i < size) ? DTMF_CALL_MODE_GROUP : DTMF_CALL_MODE_NOT_GROUP;
}
#endif
void DTMF_clear_input_box(void)
{
@ -204,236 +213,249 @@ void DTMF_Append(const char code)
g_dtmf_input_box[g_dtmf_input_box_index++] = code;
}
void DTMF_HandleRequest(void)
{ // proccess the RX'ed DTMF characters
char String[21];
unsigned int Offset;
if (!g_dtmf_rx_pending)
return; // nothing new received
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF)
{ // we're busy scanning
DTMF_clear_RX();
return;
}
#ifdef ENABLE_KILL_REVIVE
if (!g_rx_vfo->channel.dtmf_decoding_enable && !g_eeprom.config.setting.radio_disabled)
#else
if (!g_rx_vfo->channel.dtmf_decoding_enable)
#endif
{ // D-DCD is disabled or we're enabled
DTMF_clear_RX();
return;
}
g_dtmf_rx_pending = false;
#ifdef ENABLE_KILL_REVIVE
if (g_dtmf_rx_index >= 9)
{ // look for the RADIO DISABLE code
#ifdef ENABLE_DTMF_CALLING
void DTMF_HandleRequest(void)
{ // proccess the RX'ed DTMF characters
sprintf(String, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.kill_code);
char String[21];
unsigned int Offset;
Offset = g_dtmf_rx_index - strlen(String);
if (!g_dtmf_rx_pending)
return; // nothing new received
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
{ // bugger
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF)
{ // we're busy scanning
DTMF_clear_RX();
return;
}
if (g_eeprom.config.setting.dtmf.permit_remote_kill != 0)
{
g_eeprom.config.setting.radio_disabled = true; // :(
#ifdef ENABLE_DTMF_KILL_REVIVE
if (!g_rx_vfo->channel.dtmf_decoding_enable && !g_eeprom.config.setting.radio_disabled)
#else
if (!g_rx_vfo->channel.dtmf_decoding_enable)
#endif
{ // D-DCD is disabled or we're enabled
DTMF_clear_RX();
return;
}
g_dtmf_rx_pending = false;
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_dtmf_rx_index >= 9)
{ // look for the RADIO DISABLE code
sprintf(String, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.kill_code);
Offset = g_dtmf_rx_index - strlen(String);
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
{ // bugger
if (g_eeprom.config.setting.dtmf.permit_remote_kill != 0)
{
g_eeprom.config.setting.radio_disabled = true; // :(
DTMF_clear_RX();
SETTINGS_save();
g_dtmf_reply_state = DTMF_REPLY_AB;
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
{
FM_turn_off();
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
#endif
}
else
{
g_dtmf_reply_state = DTMF_REPLY_NONE;
}
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
g_update_status = true;
return;
}
}
if (g_dtmf_rx_index >= 9)
{ // look for the REVIVE code
sprintf(String, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.revive_code);
Offset = g_dtmf_rx_index - strlen(String);
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
{ // shit, we're back !
g_eeprom.config.setting.radio_disabled = false;
DTMF_clear_RX();
SETTINGS_save();
g_dtmf_reply_state = DTMF_REPLY_AB;
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
{
FM_turn_off();
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
#endif
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
g_update_status = true;
return;
}
else
{
g_dtmf_reply_state = DTMF_REPLY_NONE;
}
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
g_update_status = true;
return;
}
}
if (g_dtmf_rx_index >= 9)
{ // look for the REVIVE code
#endif
sprintf(String, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.revive_code);
if (g_dtmf_rx_index >= 2)
{ // look for ACK reply
strcpy(String, "AB");
Offset = g_dtmf_rx_index - strlen(String);
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
{ // shit, we're back !
{ // ends with "AB"
g_eeprom.config.setting.radio_disabled = false;
DTMF_clear_RX();
SETTINGS_save();
g_dtmf_reply_state = DTMF_REPLY_AB;
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
g_update_status = true;
return;
if (g_dtmf_reply_state != DTMF_REPLY_NONE) // 1of11
// if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) // 1of11
{
g_dtmf_state = DTMF_STATE_TX_SUCC;
DTMF_clear_RX();
g_update_display = true;
return;
}
}
}
#endif
if (g_dtmf_rx_index >= 2)
{ // look for ACK reply
strcpy(String, "AB");
Offset = g_dtmf_rx_index - strlen(String);
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
{ // ends with "AB"
if (g_dtmf_reply_state != DTMF_REPLY_NONE) // 1of11
// if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT) // 1of11
{
g_dtmf_state = DTMF_STATE_TX_SUCC;
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT &&
g_dtmf_call_mode == DTMF_CALL_MODE_NOT_GROUP &&
g_dtmf_rx_index >= 9)
{ // waiting for a reply
sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.config.setting.dtmf.separate_code, "AAAAA");
Offset = g_dtmf_rx_index - strlen(String);
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), false))
{ // we got a response
g_dtmf_state = DTMF_STATE_CALL_OUT_RSP;
DTMF_clear_RX();
g_update_display = true;
return;
}
}
}
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT &&
g_dtmf_call_mode == DTMF_CALL_MODE_NOT_GROUP &&
g_dtmf_rx_index >= 9)
{ // waiting for a reply
sprintf(String, "%s%c%s", g_dtmf_string, g_eeprom.config.setting.dtmf.separate_code, "AAAAA");
Offset = g_dtmf_rx_index - strlen(String);
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), false))
{ // we got a response
g_dtmf_state = DTMF_STATE_CALL_OUT_RSP;
DTMF_clear_RX();
g_update_display = true;
}
}
#ifdef ENABLE_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
return; // we've been disabled
#endif
if (g_dtmf_rx_index >= 7)
{ // see if we're being called
g_dtmf_IsGroupCall = false;
sprintf(String, "%s%c", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code);
Offset = g_dtmf_rx_index - strlen(String) - 3;
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
{ // it's for us !
g_dtmf_call_state = DTMF_CALL_STATE_RECEIVED;
memset(g_dtmf_callee, 0, sizeof(g_dtmf_callee));
memset(g_dtmf_caller, 0, sizeof(g_dtmf_caller));
memcpy(g_dtmf_callee, g_dtmf_rx + Offset + 0, 3);
memcpy(g_dtmf_caller, g_dtmf_rx + Offset + 4, 3);
DTMF_clear_RX();
g_update_display = true;
switch (g_eeprom.config.setting.dtmf.decode_response)
{
case DTMF_DEC_RESPONSE_BOTH:
g_dtmf_decode_ring_tick_500ms = dtmf_decode_ring_500ms;
// Fallthrough
case DTMF_DEC_RESPONSE_REPLY:
g_dtmf_reply_state = DTMF_REPLY_AAAAA;
break;
case DTMF_DEC_RESPONSE_RING:
g_dtmf_decode_ring_tick_500ms = dtmf_decode_ring_500ms;
break;
default:
case DTMF_DEC_RESPONSE_NONE:
g_dtmf_decode_ring_tick_500ms = 0;
#ifdef ENABLE_DTMF_KILL_REVIVE
if (g_eeprom.config.setting.radio_disabled)
return; // we've been disabled
#endif
if (g_dtmf_rx_index >= 7)
{ // see if we're being called
g_dtmf_IsGroupCall = false;
sprintf(String, "%s%c", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code);
Offset = g_dtmf_rx_index - strlen(String) - 3;
if (DTMF_CompareMessage(g_dtmf_rx + Offset, String, strlen(String), true))
{ // it's for us !
g_dtmf_call_state = DTMF_CALL_STATE_RECEIVED;
memset(g_dtmf_callee, 0, sizeof(g_dtmf_callee));
memset(g_dtmf_caller, 0, sizeof(g_dtmf_caller));
memcpy(g_dtmf_callee, g_dtmf_rx + Offset + 0, 3);
memcpy(g_dtmf_caller, g_dtmf_rx + Offset + 4, 3);
DTMF_clear_RX();
g_update_display = true;
switch (g_eeprom.config.setting.dtmf.decode_response)
{
case DTMF_DEC_RESPONSE_BOTH:
g_dtmf_decode_ring_tick_500ms = dtmf_decode_ring_500ms;
// Fallthrough
case DTMF_DEC_RESPONSE_REPLY:
g_dtmf_reply_state = DTMF_REPLY_AAAAA;
break;
case DTMF_DEC_RESPONSE_RING:
g_dtmf_decode_ring_tick_500ms = dtmf_decode_ring_500ms;
break;
default:
case DTMF_DEC_RESPONSE_NONE:
g_dtmf_decode_ring_tick_500ms = 0;
g_dtmf_reply_state = DTMF_REPLY_NONE;
break;
}
if (g_dtmf_IsGroupCall)
g_dtmf_reply_state = DTMF_REPLY_NONE;
break;
}
if (g_dtmf_IsGroupCall)
g_dtmf_reply_state = DTMF_REPLY_NONE;
}
}
}
#endif
bool DTMF_Reply(void)
{
const uint16_t delay_ms = ((g_eeprom.config.setting.dtmf.preload_time < 15) ? 15 : g_eeprom.config.setting.dtmf.preload_time) * 10;
const char *pString = NULL;
char str[23];
#ifdef ENABLE_DTMF_CALLING
char str[23];
#endif
switch (g_dtmf_reply_state)
{
case DTMF_REPLY_ANI:
case DTMF_REPLY_STR:
pString = g_dtmf_string;
break;
if (g_dtmf_call_mode != DTMF_CALL_MODE_DTMF)
{ // append our ID code onto the end of the DTMF code to send
sprintf(str, "%s%c%s", g_dtmf_string, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.ani_id);
#ifdef ENABLE_DTMF_CALLING
case DTMF_REPLY_ANI:
pString = g_dtmf_string;
if (g_dtmf_call_mode != DTMF_CALL_MODE_DTMF)
{ // append our ID code onto the end of the DTMF code to send
sprintf(str, "%s%c%s", g_dtmf_string, g_eeprom.config.setting.dtmf.separate_code, g_eeprom.config.setting.dtmf.ani_id);
pString = str;
}
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("dtmf tx reply ani %s\r\n", pString);
#endif
break;
case DTMF_REPLY_AB:
pString = "AB";
break;
case DTMF_REPLY_AAAAA:
sprintf(str, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, "AAAAA");
pString = str;
}
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("dtmf tx reply ani %s\r\n", pString);
#endif
break;
case DTMF_REPLY_AB:
pString = "AB";
break;
case DTMF_REPLY_AAAAA:
sprintf(str, "%s%c%s", g_eeprom.config.setting.dtmf.ani_id, g_eeprom.config.setting.dtmf.separate_code, "AAAAA");
pString = str;
break;
break;
case DTMF_REPLY_NONE:
#endif
default:
case DTMF_REPLY_NONE:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("dtmf tx reply none %s\r\n", g_dtmf_string);
#endif
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO ||
g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_OFF ||
g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_EOT)
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO ||
g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_OFF ||
g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_EOT)
{
g_dtmf_reply_state = DTMF_REPLY_NONE;
return false;
@ -446,7 +468,7 @@ bool DTMF_Reply(void)
g_dtmf_reply_state = DTMF_REPLY_NONE;
if (pString == NULL)
if (pString == NULL || strlen(pString) == 0)
return false;
if (g_eeprom.config.setting.dtmf.side_tone)

View File

@ -20,7 +20,7 @@
#include <stdbool.h>
#include <stdint.h>
#define MAX_DTMF_CONTACTS 16
#define MAX_DTMF_CONTACTS 16
enum { // seconds
DTMF_HOLD_MIN = 5,
@ -34,36 +34,45 @@ enum dtmf_state_e {
};
typedef enum dtmf_state_e dtmf_state_t;
enum dtmf_call_state_e {
DTMF_CALL_STATE_NONE = 0,
DTMF_CALL_STATE_CALL_OUT,
DTMF_CALL_STATE_RECEIVED,
DTMF_CALL_STATE_RECEIVED_STAY
};
typedef enum dtmf_call_state_e dtmf_call_state_t;
#ifdef ENABLE_DTMF_CALLING
enum dtmf_call_state_e {
DTMF_CALL_STATE_NONE = 0,
DTMF_CALL_STATE_CALL_OUT,
DTMF_CALL_STATE_RECEIVED,
DTMF_CALL_STATE_RECEIVED_STAY
};
typedef enum dtmf_call_state_e dtmf_call_state_t;
enum dtmf_decode_response_e {
DTMF_DEC_RESPONSE_NONE = 0,
DTMF_DEC_RESPONSE_RING,
DTMF_DEC_RESPONSE_REPLY,
DTMF_DEC_RESPONSE_BOTH
};
typedef enum dtmf_decode_response_e dtmf_decode_response_t;
enum dtmf_reply_state_e {
DTMF_REPLY_NONE = 0,
DTMF_REPLY_STR,
DTMF_REPLY_ANI,
DTMF_REPLY_AB,
DTMF_REPLY_AAAAA
};
typedef enum dtmf_reply_state_e dtmf_reply_state_t;
enum dtmf_decode_response_e {
DTMF_DEC_RESPONSE_NONE = 0,
DTMF_DEC_RESPONSE_RING,
DTMF_DEC_RESPONSE_REPLY,
DTMF_DEC_RESPONSE_BOTH
};
typedef enum dtmf_decode_response_e dtmf_decode_response_t;
enum dtmf_reply_state_e {
DTMF_REPLY_NONE = 0,
DTMF_REPLY_ANI,
DTMF_REPLY_AB,
DTMF_REPLY_AAAAA
};
typedef enum dtmf_reply_state_e dtmf_reply_state_t;
enum dtmf_call_mode_e {
DTMF_CALL_MODE_NOT_GROUP = 0,
DTMF_CALL_MODE_GROUP,
DTMF_CALL_MODE_DTMF
};
typedef enum dtmf_call_mode_e dtmf_call_mode_t;
enum dtmf_call_mode_e {
DTMF_CALL_MODE_NOT_GROUP = 0,
DTMF_CALL_MODE_GROUP,
DTMF_CALL_MODE_DTMF
};
typedef enum dtmf_call_mode_e dtmf_call_mode_t;
#else
enum dtmf_reply_state_e {
DTMF_REPLY_NONE = 0,
DTMF_REPLY_STR
};
typedef enum dtmf_reply_state_e dtmf_reply_state_t;
#endif
extern char g_dtmf_string[15];
@ -72,40 +81,51 @@ extern uint8_t g_dtmf_input_box_index;
extern bool g_dtmf_input_mode;
extern uint8_t g_dtmf_prev_index;
extern char g_dtmf_rx[17];
extern uint8_t g_dtmf_rx_index;
extern uint8_t g_dtmf_rx_timeout;
extern bool g_dtmf_rx_pending;
#ifdef ENABLE_DTMF_LIVE_DECODER
extern char g_dtmf_rx_live[20];
extern uint8_t g_dtmf_rx_live_timeout;
extern char g_dtmf_rx_live[20];
extern uint8_t g_dtmf_rx_live_timeout;
#endif
extern bool g_dtmf_is_contact_valid;
extern char g_dtmf_id[4];
extern char g_dtmf_caller[4];
extern char g_dtmf_callee[4];
extern dtmf_state_t g_dtmf_state;
extern uint8_t g_dtmf_decode_ring_tick_500ms;
extern uint8_t g_dtmf_chosen_contact;
extern uint8_t g_dtmf_auto_reset_time_500ms;
extern dtmf_call_state_t g_dtmf_call_state;
extern dtmf_reply_state_t g_dtmf_reply_state;
extern dtmf_call_mode_t g_dtmf_call_mode;
extern bool g_dtmf_is_tx;
extern uint8_t g_dtmf_tx_stop_tick_500ms;
#ifdef ENABLE_DTMF_CALLING
extern char g_dtmf_rx[17];
extern uint8_t g_dtmf_rx_index;
extern uint8_t g_dtmf_rx_timeout;
extern bool g_dtmf_rx_pending;
void DTMF_clear_RX(void);
extern bool g_dtmf_is_contact_valid;
extern char g_dtmf_id[4];
extern char g_dtmf_caller[4];
extern char g_dtmf_callee[4];
extern dtmf_state_t g_dtmf_state;
extern uint8_t g_dtmf_decode_ring_tick_500ms;
extern uint8_t g_dtmf_chosen_contact;
extern uint8_t g_dtmf_auto_reset_time_500ms;
extern dtmf_call_state_t g_dtmf_call_state;
extern dtmf_call_mode_t g_dtmf_call_mode;
#endif
extern dtmf_reply_state_t g_dtmf_reply_state;
extern bool g_dtmf_is_tx;
extern uint8_t g_dtmf_tx_stop_tick_500ms;
#ifdef ENABLE_DTMF_CALLING
void DTMF_clear_RX(void);
#endif
bool DTMF_ValidateCodes(char *pCode, const unsigned int size);
bool DTMF_GetContact(const int Index, char *pContact);
bool DTMF_FindContact(const char *pContact, char *pResult);
#ifdef ENABLE_DTMF_CALLING
bool DTMF_GetContact(const int Index, char *pContact);
bool DTMF_FindContact(const char *pContact, char *pResult);
#endif
char DTMF_GetCharacter(const unsigned int code);
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, const unsigned int size, const bool flag);
dtmf_call_mode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
#ifdef ENABLE_DTMF_CALLING
bool DTMF_CompareMessage(const char *pDTMF, const char *pTemplate, const unsigned int size, const bool flag);
dtmf_call_mode_t DTMF_CheckGroupCall(const char *pDTMF, const unsigned int size);
#endif
void DTMF_clear_input_box(void);
void DTMF_Append(const char vode);
void DTMF_HandleRequest(void);
#ifdef ENABLE_DTMF_CALLING
void DTMF_HandleRequest(void);
#endif
bool DTMF_Reply(void);
#endif

View File

@ -214,26 +214,32 @@ void GENERIC_Key_PTT(bool key_pressed)
g_dtmf_input_box[g_dtmf_input_box_index] = 0; // NULL term the string
// append our DTMF ID to the inputted DTMF code -
#if 0
// QS
if (g_dtmf_input_box_index == 3)
g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3);
else
g_dtmf_call_mode = DTMF_CALL_MODE_DTMF;
#else
// 1of11
if (g_dtmf_input_box_index == 3 && g_dtmf_input_box[0] != '*' && g_dtmf_input_box[0] != '#')
g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3);
else
g_dtmf_call_mode = DTMF_CALL_MODE_DTMF;
#ifdef ENABLE_DTMF_CALLING
#if 0
// QS
if (g_dtmf_input_box_index == 3)
g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3);
else
g_dtmf_call_mode = DTMF_CALL_MODE_DTMF;
#else
// 1of11
if (g_dtmf_input_box_index == 3 && g_dtmf_input_box[0] != '*' && g_dtmf_input_box[0] != '#')
g_dtmf_call_mode = DTMF_CheckGroupCall(g_dtmf_input_box, 3);
else
g_dtmf_call_mode = DTMF_CALL_MODE_DTMF;
#endif
#endif
// remember the DTMF string
g_dtmf_prev_index = g_dtmf_input_box_index;
strcpy(g_dtmf_string, g_dtmf_input_box);
g_dtmf_reply_state = DTMF_REPLY_ANI;
g_dtmf_state = DTMF_STATE_0;
#ifdef ENABLE_DTMF_CALLING
g_dtmf_reply_state = DTMF_REPLY_ANI;
g_dtmf_state = DTMF_STATE_0;
#else
g_dtmf_reply_state = DTMF_REPLY_STR; // just send the straight string
#endif
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("generic ptt tx %s\r\n", g_dtmf_string);

View File

@ -703,12 +703,14 @@ void MAIN_Key_EXIT(bool key_pressed, bool key_held)
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE && g_current_function != FUNCTION_TRANSMIT)
{ // clear CALL mode being displayed
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
return;
}
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE && g_current_function != FUNCTION_TRANSMIT)
{ // clear CALL mode being displayed
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_update_display = true;
return;
}
#endif
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)

View File

@ -261,7 +261,9 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
case MENU_S_ADD2:
case MENU_STE:
case MENU_DTMF_ST:
case MENU_DTMF_DCD:
#ifdef ENABLE_DTMF_CALLING
case MENU_DTMF_DCD:
#endif
#ifdef ENABLE_DTMF_LIVE_DECODER
case MENU_DTMF_LIVE_DEC:
#endif
@ -322,11 +324,6 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
*pMax = 2;
break;
case MENU_DTMF_RSP:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_dtmf_rsp) - 1;
break;
#ifdef ENABLE_MDC1200
case MENU_MDC1200_MODE:
*pMin = 0;
@ -344,16 +341,28 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
*pMax = ARRAY_SIZE(g_sub_menu_ptt_id) - 1;
break;
#ifdef ENABLE_DTMF_CALLING
case MENU_DTMF_RSP:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_dtmf_rsp) - 1;
break;
case MENU_DTMF_HOLD:
*pMin = DTMF_HOLD_MIN;
*pMax = DTMF_HOLD_MAX;
break;
case MENU_DTMF_LIST:
*pMin = 1;
*pMax = 16;
break;
#endif
case MENU_BAT_TXT:
*pMin = 0;
*pMax = ARRAY_SIZE(g_sub_menu_bat_text) - 1;
break;
case MENU_DTMF_HOLD:
*pMin = DTMF_HOLD_MIN;
*pMax = DTMF_HOLD_MAX;
break;
#ifdef ENABLE_DTMF_TIMING_SETTINGS
case MENU_DTMF_PRE:
*pMin = 3;
@ -369,11 +378,6 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
break;
#endif
case MENU_DTMF_LIST:
*pMin = 1;
*pMax = 16;
break;
#ifdef ENABLE_TX_POWER_CAL_MENU
case MENU_TX_CALI:
*pMin = 0;
@ -741,13 +745,33 @@ void MENU_AcceptSetting(void)
g_eeprom.config.setting.dtmf.side_tone = g_sub_menu_selection;
break;
case MENU_DTMF_RSP:
g_eeprom.config.setting.dtmf.decode_response = g_sub_menu_selection;
break;
#ifdef ENABLE_DTMF_CALLING
case MENU_DTMF_RSP:
g_eeprom.config.setting.dtmf.decode_response = g_sub_menu_selection;
break;
case MENU_DTMF_HOLD:
g_eeprom.config.setting.dtmf.auto_reset_time = g_sub_menu_selection;
break;
case MENU_DTMF_HOLD:
g_eeprom.config.setting.dtmf.auto_reset_time = g_sub_menu_selection;
break;
case MENU_DTMF_DCD:
g_tx_vfo->channel.dtmf_decoding_enable = g_sub_menu_selection;
DTMF_clear_RX();
g_request_save_channel = 1;
return;
case MENU_DTMF_LIST:
g_dtmf_chosen_contact = g_sub_menu_selection - 1;
if (g_dtmf_is_contact_valid)
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
g_dtmf_input_mode = true;
g_dtmf_input_box_index = 3;
memcpy(g_dtmf_input_box, g_dtmf_id, 4);
g_request_display_screen = DISPLAY_INVALID;
}
return;
#endif
#ifdef ENABLE_DTMF_TIMING_SETTINGS
case MENU_DTMF_PRE:
@ -798,12 +822,6 @@ void MENU_AcceptSetting(void)
g_eeprom.config.setting.battery_text = g_sub_menu_selection;
break;
case MENU_DTMF_DCD:
g_tx_vfo->channel.dtmf_decoding_enable = g_sub_menu_selection;
DTMF_clear_RX();
g_request_save_channel = 1;
return;
#ifdef ENABLE_DTMF_LIVE_DECODER
case MENU_DTMF_LIVE_DEC:
g_eeprom.config.setting.dtmf_live_decoder = g_sub_menu_selection;
@ -816,18 +834,6 @@ void MENU_AcceptSetting(void)
break;
#endif
case MENU_DTMF_LIST:
g_dtmf_chosen_contact = g_sub_menu_selection - 1;
if (g_dtmf_is_contact_valid)
{
GUI_SelectNextDisplay(DISPLAY_MAIN);
g_dtmf_input_mode = true;
g_dtmf_input_box_index = 3;
memcpy(g_dtmf_input_box, g_dtmf_id, 4);
g_request_display_screen = DISPLAY_INVALID;
}
return;
case MENU_PON_MSG:
g_eeprom.config.setting.power_on_display_mode = g_sub_menu_selection;
break;
@ -871,21 +877,21 @@ void MENU_AcceptSetting(void)
return;
#ifdef ENABLE_SIDE_BUTT_MENU
case MENU_SIDE1_SHORT:
g_eeprom.config.setting.key1_short = g_sub_menu_selection;
break;
case MENU_SIDE1_LONG:
g_eeprom.config.setting.key1_long = g_sub_menu_selection;
break;
case MENU_SIDE2_SHORT:
g_eeprom.config.setting.key2_short = g_sub_menu_selection;
break;
case MENU_SIDE2_LONG:
g_eeprom.config.setting.key2_long = g_sub_menu_selection;
break;
case MENU_SIDE1_SHORT:
g_eeprom.config.setting.key1_short = g_sub_menu_selection;
break;
case MENU_SIDE1_LONG:
g_eeprom.config.setting.key1_long = g_sub_menu_selection;
break;
case MENU_SIDE2_SHORT:
g_eeprom.config.setting.key2_short = g_sub_menu_selection;
break;
case MENU_SIDE2_LONG:
g_eeprom.config.setting.key2_long = g_sub_menu_selection;
break;
#endif
case MENU_RESET:
@ -1190,9 +1196,9 @@ void MENU_ShowCurrentSetting(void)
break;
#ifdef ENABLE_KEYLOCK
case MENU_AUTO_KEY_LOCK:
g_sub_menu_selection = g_eeprom.config.setting.auto_key_lock;
break;
case MENU_AUTO_KEY_LOCK:
g_sub_menu_selection = g_eeprom.config.setting.auto_key_lock;
break;
#endif
#ifdef ENABLE_SCAN_RANGES
@ -1257,47 +1263,57 @@ void MENU_ShowCurrentSetting(void)
g_sub_menu_selection = RADIO_FindNextChannel(0, 1, true, 1);
break;
#ifdef ENABLE_ALARM
#ifdef ENABLE_ALARM
case MENU_ALARM_MODE:
g_sub_menu_selection = g_eeprom.config.setting.alarm_mode;
break;
#endif
#endif
case MENU_DTMF_ST:
g_sub_menu_selection = g_eeprom.config.setting.dtmf.side_tone;
break;
case MENU_DTMF_RSP:
g_sub_menu_selection = g_eeprom.config.setting.dtmf.decode_response;
break;
#ifdef ENABLE_DTMF_CALLING
case MENU_DTMF_RSP:
g_sub_menu_selection = g_eeprom.config.setting.dtmf.decode_response;
break;
case MENU_DTMF_HOLD:
g_sub_menu_selection = g_eeprom.config.setting.dtmf.auto_reset_time;
if (g_sub_menu_selection <= DTMF_HOLD_MIN)
g_sub_menu_selection = DTMF_HOLD_MIN;
else
if (g_sub_menu_selection <= 10)
g_sub_menu_selection = 10;
else
if (g_sub_menu_selection <= 20)
g_sub_menu_selection = 20;
else
if (g_sub_menu_selection <= 30)
g_sub_menu_selection = 30;
else
if (g_sub_menu_selection <= 40)
g_sub_menu_selection = 40;
else
if (g_sub_menu_selection <= 50)
g_sub_menu_selection = 50;
else
if (g_sub_menu_selection < DTMF_HOLD_MAX)
g_sub_menu_selection = 50;
else
g_sub_menu_selection = DTMF_HOLD_MAX;
break;
case MENU_DTMF_HOLD:
g_sub_menu_selection = g_eeprom.config.setting.dtmf.auto_reset_time;
case MENU_DTMF_DCD:
g_sub_menu_selection = g_tx_vfo->channel.dtmf_decoding_enable;
break;
if (g_sub_menu_selection <= DTMF_HOLD_MIN)
g_sub_menu_selection = DTMF_HOLD_MIN;
else
if (g_sub_menu_selection <= 10)
g_sub_menu_selection = 10;
else
if (g_sub_menu_selection <= 20)
g_sub_menu_selection = 20;
else
if (g_sub_menu_selection <= 30)
g_sub_menu_selection = 30;
else
if (g_sub_menu_selection <= 40)
g_sub_menu_selection = 40;
else
if (g_sub_menu_selection <= 50)
g_sub_menu_selection = 50;
else
if (g_sub_menu_selection < DTMF_HOLD_MAX)
g_sub_menu_selection = 50;
else
g_sub_menu_selection = DTMF_HOLD_MAX;
break;
case MENU_DTMF_LIST:
g_sub_menu_selection = g_dtmf_chosen_contact + 1;
break;
#endif
#ifdef ENABLE_DTMF_TIMING_SETTINGS
case MENU_DTMF_PRE:
@ -1339,14 +1355,6 @@ void MENU_ShowCurrentSetting(void)
g_sub_menu_selection = g_eeprom.config.setting.battery_text;
return;
case MENU_DTMF_DCD:
g_sub_menu_selection = g_tx_vfo->channel.dtmf_decoding_enable;
break;
case MENU_DTMF_LIST:
g_sub_menu_selection = g_dtmf_chosen_contact + 1;
break;
#ifdef ENABLE_DTMF_LIVE_DECODER
case MENU_DTMF_LIVE_DEC:
g_sub_menu_selection = g_eeprom.config.setting.dtmf_live_decoder;
@ -1365,49 +1373,49 @@ void MENU_ShowCurrentSetting(void)
g_sub_menu_selection = g_tx_vfo->channel.mod_mode;
break;
/*
#ifdef ENABLE_AM_FIX
#ifdef ENABLE_AM_FIX
case MENU_AM_FIX:
g_sub_menu_selection = g_eeprom.config.setting.am_fix;
break;
#endif
#endif
*/
#ifdef ENABLE_AM_FIX_TEST1
#ifdef ENABLE_AM_FIX_TEST1
case MENU_AM_FIX_TEST1:
g_sub_menu_selection = g_eeprom.config.setting.am_fix_test1;
break;
#endif
#endif
#ifdef ENABLE_NOAA
#ifdef ENABLE_NOAA
case MENU_NOAA_SCAN:
g_sub_menu_selection = g_eeprom.config.setting.noaa_auto_scan;
break;
#endif
#endif
case MENU_MEM_DEL:
#if 0
#if 0
g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.config.setting.indices.vfo[0].user, 1, false, 1);
#else
#else
g_sub_menu_selection = RADIO_FindNextChannel(g_eeprom.config.setting.indices.vfo[g_eeprom.config.setting.tx_vfo_num].user, 1, false, 1);
#endif
#endif
break;
#ifdef ENABLE_SIDE_BUTT_MENU
case MENU_SIDE1_SHORT:
g_sub_menu_selection = g_eeprom.config.setting.key1_short;
break;
case MENU_SIDE1_LONG:
g_sub_menu_selection = g_eeprom.config.setting.key1_long;
break;
case MENU_SIDE2_SHORT:
g_sub_menu_selection = g_eeprom.config.setting.key2_short;
break;
case MENU_SIDE2_LONG:
g_sub_menu_selection = g_eeprom.config.setting.key2_long;
break;
#endif
#ifdef ENABLE_SIDE_BUTT_MENU
case MENU_SIDE1_SHORT:
g_sub_menu_selection = g_eeprom.config.setting.key1_short;
break;
case MENU_SIDE1_LONG:
g_sub_menu_selection = g_eeprom.config.setting.key1_long;
break;
case MENU_SIDE2_SHORT:
g_sub_menu_selection = g_eeprom.config.setting.key2_short;
break;
case MENU_SIDE2_LONG:
g_sub_menu_selection = g_eeprom.config.setting.key2_long;
break;
#endif
case MENU_350_TX:
g_sub_menu_selection = g_eeprom.config.setting.enable_tx_350;

View File

@ -650,7 +650,9 @@ void SEARCH_Start(void)
BK4819_EnableFrequencyScan();
}
DTMF_clear_RX();
#ifdef ENABLE_DTMF_CALLING
DTMF_clear_RX();
#endif
#ifdef ENABLE_VOX
g_vox_lost = false;

View File

@ -352,7 +352,7 @@ static void cmd_051D(const uint8_t *pBuffer)
memset(data, 0xff, 8); // wipe the AES key
#endif
//#ifndef ENABLE_KILL_REVIVE
//#ifndef ENABLE_DTMF_KILL_REVIVE
if (Offset == 0x0F40)
{ // killed flag is here
data[2] = false; // remove it

Binary file not shown.

Binary file not shown.

View File

@ -56,7 +56,9 @@ void FUNCTION_Init(void)
else
g_current_code_type = CODE_TYPE_CONTINUOUS_TONE;
DTMF_clear_RX();
#ifdef ENABLE_DTMF_CALLING
DTMF_clear_RX();
#endif
g_cxcss_tail_found = false;
g_cdcss_lost = false;
@ -123,12 +125,14 @@ void FUNCTION_Select(function_type_t Function)
g_fm_restore_tick_10ms = g_eeprom.config.setting.scan_hold_time * 50;
#endif
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT ||
g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED ||
g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY)
{
g_dtmf_auto_reset_time_500ms = g_eeprom.config.setting.dtmf.auto_reset_time * 2;
}
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT ||
g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED ||
g_dtmf_call_state == DTMF_CALL_STATE_RECEIVED_STAY)
{
g_dtmf_auto_reset_time_500ms = g_eeprom.config.setting.dtmf.auto_reset_time * 2;
}
#endif
return;
@ -213,7 +217,9 @@ void FUNCTION_Select(function_type_t Function)
BK4819_DisableDTMF();
// clear the DTMF RX buffer
DTMF_clear_RX();
#ifdef ENABLE_DTMF_CALLING
DTMF_clear_RX();
#endif
#ifdef ENABLE_DTMF_LIVE_DECODER
// clear the DTMF RX live decoder buffer
@ -262,35 +268,37 @@ void FUNCTION_Select(function_type_t Function)
}
else
#endif
if (!DTMF_Reply())
{
#ifdef ENABLE_MDC1200
if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH)
{
#ifdef ENABLE_MDC1200_SIDE_BEEP
// BK4819_start_tone(880, 10, true, true);
// SYSTEM_DelayMs(120);
// BK4819_stop_tones(true);
#endif
SYSTEM_DelayMs(30);
BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.config.setting.mdc1200_id, true);
#ifdef ENABLE_MDC1200_SIDE_BEEP
BK4819_start_tone(880, 10, true, true);
SYSTEM_DelayMs(120);
BK4819_stop_tones(true);
#endif
}
else
#ifdef ENABLE_DTMF_CALLING
if (!DTMF_Reply())
#endif
if (g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{
BK4819_start_tone(APOLLO_TONE1_HZ, 28, true, false);
SYSTEM_DelayMs(APOLLO_TONE_MS);
BK4819_stop_tones(true);
#ifdef ENABLE_MDC1200
if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH)
{
#ifdef ENABLE_MDC1200_SIDE_BEEP
// BK4819_start_tone(880, 10, true, true);
// SYSTEM_DelayMs(120);
// BK4819_stop_tones(true);
#endif
SYSTEM_DelayMs(30);
BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.config.setting.mdc1200_id, true);
#ifdef ENABLE_MDC1200_SIDE_BEEP
BK4819_start_tone(880, 10, true, true);
SYSTEM_DelayMs(120);
BK4819_stop_tones(true);
#endif
}
else
#endif
if (g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
{
BK4819_start_tone(APOLLO_TONE1_HZ, 28, true, false);
SYSTEM_DelayMs(APOLLO_TONE_MS);
BK4819_stop_tones(true);
}
}
}
if (g_eeprom.config.setting.enable_scrambler)
BK4819_set_scrambler(g_current_vfo->channel.scrambler);

View File

@ -142,7 +142,9 @@ void PAN_process_10ms(void)
g_current_display_screen == DISPLAY_SEARCH ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
#endif
g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF)
{
if (g_panadapter_enabled)

38
radio.c
View File

@ -1167,24 +1167,29 @@ void RADIO_PrepareTX(void)
// ******************************
// TX is allowed
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("radio prepare tx %u %s\r\n", g_dtmf_reply_state, g_dtmf_string);
#if defined(ENABLE_DTMF_CALLING) && defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("radio prepare tx %u %s\r\n", g_dtmf_reply_state, g_dtmf_string);
#endif
if (g_dtmf_reply_state == DTMF_REPLY_ANI)
{
if (g_dtmf_call_mode == DTMF_CALL_MODE_DTMF)
#ifdef ENABLE_DTMF_CALLING
if (g_dtmf_reply_state == DTMF_REPLY_STR || g_dtmf_reply_state == DTMF_REPLY_ANI)
{
g_dtmf_is_tx = true;
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_dtmf_tx_stop_tick_500ms = dtmf_txstop_500ms;
if (g_dtmf_call_mode == DTMF_CALL_MODE_DTMF)
{
g_dtmf_is_tx = true;
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_dtmf_tx_stop_tick_500ms = dtmf_txstop_500ms;
}
else
{
g_dtmf_call_state = DTMF_CALL_STATE_CALL_OUT;
g_dtmf_is_tx = false;
}
}
else
{
g_dtmf_call_state = DTMF_CALL_STATE_CALL_OUT;
g_dtmf_is_tx = false;
}
}
#else
if (g_dtmf_reply_state == DTMF_REPLY_STR)
g_dtmf_is_tx = false;
#endif
FUNCTION_Select(FUNCTION_TRANSMIT);
}
@ -1233,7 +1238,10 @@ void RADIO_tx_eot(void)
}
#endif
if (g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
if (
#ifdef ENABLE_DTMF_CALLING
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
#endif
(g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_EOT || g_current_vfo->channel.dtmf_ptt_id_tx_mode == PTT_ID_BOTH))
{ // end-of-tx
if (g_eeprom.config.setting.dtmf.side_tone)

View File

@ -236,7 +236,7 @@ void SETTINGS_read_eeprom(void)
g_eeprom.config.setting.dtmf.code_persist_time = (g_eeprom.config.setting.dtmf.code_persist_time < 5 || g_eeprom.config.setting.dtmf.code_persist_time > 20) ? 10 : g_eeprom.config.setting.dtmf.code_persist_time;
g_eeprom.config.setting.dtmf.code_interval_time = (g_eeprom.config.setting.dtmf.code_interval_time < 5 || g_eeprom.config.setting.dtmf.code_interval_time > 20) ? 10 : g_eeprom.config.setting.dtmf.code_interval_time;
#if 0
#ifdef ENABLE_KILL_REVIVE
#ifdef ENABLE_DTMF_KILL_REVIVE
g_eeprom.config.setting.dtmf.permit_remote_kill = (g_eeprom.config.setting.dtmf.permit_remote_kill < 2) ? g_eeprom.config.setting.dtmf.permit_remote_kill : 0;
#else
g_eeprom.config.setting.dtmf.permit_remote_kill = 0;
@ -249,7 +249,7 @@ void SETTINGS_read_eeprom(void)
strcpy(g_eeprom.config.setting.dtmf.ani_id, "123");
}
#ifdef ENABLE_KILL_REVIVE
#ifdef ENABLE_DTMF_KILL_REVIVE
// 0EE8..0EEF
if (!DTMF_ValidateCodes(g_eeprom.config.setting.dtmf.kill_code, sizeof(g_eeprom.config.setting.dtmf.kill_code)))
{
@ -308,7 +308,7 @@ void SETTINGS_read_eeprom(void)
// 0F40..0F47
g_eeprom.config.setting.freq_lock = (g_eeprom.config.setting.freq_lock < FREQ_LOCK_LAST) ? g_eeprom.config.setting.freq_lock : FREQ_LOCK_NORMAL;
// g_eeprom.config.setting.enable_tx_350 = (g_eeprom.config.setting.enable_tx_350 < 2) ? g_eeprom.config.setting.enable_tx_350 : false;
#ifdef ENABLE_KILL_REVIVE
#ifdef ENABLE_DTMF_KILL_REVIVE
g_eeprom.config.setting.radio_disabled = (g_eeprom.config.setting.radio_disabled < 2) ? g_eeprom.config.setting.radio_disabled : 0;
#else
g_eeprom.config.setting.radio_disabled = 0;
@ -332,7 +332,7 @@ void SETTINGS_read_eeprom(void)
#else
#ifndef ENABLE_KILL_REVIVE
#ifndef ENABLE_DTMF_KILL_REVIVE
memset(g_eeprom.config.setting.dtmf.kill_code, 0, sizeof(g_eeprom.config.setting.dtmf.kill_code));
memset(g_eeprom.config.setting.dtmf.revive_code, 0, sizeof(g_eeprom.config.setting.dtmf.revive_code));
@ -344,7 +344,7 @@ void SETTINGS_read_eeprom(void)
memset(&g_eeprom.config.setting.aes_key, 0xff, sizeof(g_eeprom.config.setting.aes_key));
#endif
#ifndef ENABLE_KILL_REVIVE
#ifndef ENABLE_DTMF_KILL_REVIVE
g_eeprom.config.setting.radio_disabled = 0;
#endif
@ -459,7 +459,7 @@ void SETTINGS_save(void)
memset(&g_eeprom.config.setting.unused8, 0xff, sizeof(g_eeprom.config.setting.unused8));
#endif
#ifndef ENABLE_KILL_REVIVE
#ifndef ENABLE_DTMF_KILL_REVIVE
g_eeprom.config.setting.radio_disabled = 0;
#endif

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) ||