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

Fix DTMF call bug

This commit is contained in:
OneOfEleven 2023-10-16 21:59:17 +01:00
parent 1c736497f4
commit 695cf81d17
13 changed files with 61 additions and 74 deletions

View File

@ -316,7 +316,7 @@
switch (g_current_function)
{
case FUNCTION_TRANSMIT:
case FUNCTION_BAND_SCOPE:
case FUNCTION_PANADAPTER:
case FUNCTION_POWER_SAVE:
#ifdef ENABLE_AM_FIX_SHOW_DATA
counter = display_update_rate; // queue up a display update as soon as we switch to RX mode

View File

@ -90,8 +90,7 @@ void ACTION_Monitor(void)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{
g_scan_pause_delay_in_10ms = scan_pause_delay_in_1_10ms;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = scan_pause_1_10ms;
g_scan_pause_mode = true;
}
@ -200,8 +199,7 @@ void ACTION_Scan(bool bRestart)
// jump to the next channel
APP_channel_next(true, g_scan_state_dir);
g_scan_pause_delay_in_10ms = 1;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = 0;
g_update_status = true;
return;
@ -252,8 +250,7 @@ void ACTION_Scan(bool bRestart)
// jump to the next channel
APP_channel_next(true, g_scan_state_dir);
g_scan_pause_delay_in_10ms = 1;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = 0;
g_update_status = true;
}

View File

@ -103,9 +103,8 @@ static void APP_check_for_incoming_rx(void)
if (g_css_scan_mode != CSS_SCAN_MODE_OFF && g_rx_reception_mode == RX_MODE_NONE)
{ // CTCSS/DTS scanning
g_scan_pause_delay_in_10ms = scan_pause_delay_in_5_10ms;
g_scan_schedule_scan_listen = false;
g_rx_reception_mode = RX_MODE_DETECTED;
g_scan_pause_10ms = scan_pause_5_10ms;
g_rx_reception_mode = RX_MODE_DETECTED;
}
if (g_eeprom.dual_watch == DUAL_WATCH_OFF)
@ -166,8 +165,7 @@ static void APP_check_for_incoming_rx(void)
return;
}
g_scan_pause_delay_in_10ms = scan_pause_delay_in_3_10ms;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = scan_pause_3_10ms;
}
g_rx_reception_mode = RX_MODE_DETECTED;
@ -409,8 +407,7 @@ Skip:
break;
case SCAN_RESUME_CO:
g_scan_pause_delay_in_10ms = scan_pause_delay_in_7_10ms;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = scan_pause_7_10ms;
break;
case SCAN_RESUME_SE:
@ -470,7 +467,7 @@ static void APP_process_function(void)
APP_check_for_incoming_rx();
break;
case FUNCTION_BAND_SCOPE:
case FUNCTION_PANADAPTER:
break;
}
@ -505,16 +502,14 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
case SCAN_RESUME_TO:
if (!g_scan_pause_mode)
{
g_scan_pause_delay_in_10ms = scan_pause_delay_in_1_10ms;
g_scan_schedule_scan_listen = false;
g_scan_pause_mode = true;
g_scan_pause_10ms = scan_pause_1_10ms;
g_scan_pause_mode = true;
}
break;
case SCAN_RESUME_CO:
case SCAN_RESUME_SE:
g_scan_pause_delay_in_10ms = 0;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = 0;
break;
}
@ -697,9 +692,9 @@ static void APP_next_freq(void)
RADIO_setup_registers(true);
#ifdef ENABLE_FASTER_CHANNEL_SCAN
g_scan_pause_delay_in_10ms = 8; // 80ms
g_scan_pause_10ms = 8; // 80ms
#else
g_scan_pause_delay_in_10ms = scan_pause_delay_in_6_10ms;
g_scan_pause_10ms = scan_pause_6_10ms;
#endif
}
else
@ -708,9 +703,9 @@ static void APP_next_freq(void)
BK4819_set_rf_frequency(frequency, true);
#ifdef ENABLE_FASTER_CHANNEL_SCAN
g_scan_pause_delay_in_10ms = 10; // 100ms
g_scan_pause_10ms = 10; // 100ms
#else
g_scan_pause_delay_in_10ms = scan_pause_delay_in_6_10ms;
g_scan_pause_10ms = scan_pause_6_10ms;
#endif
}
@ -809,9 +804,9 @@ static void APP_next_channel(void)
}
#ifdef ENABLE_FASTER_CHANNEL_SCAN
g_scan_pause_delay_in_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
g_scan_pause_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
#else
g_scan_pause_delay_in_10ms = scan_pause_delay_in_3_10ms;
g_scan_pause_10ms = scan_pause_3_10ms;
#endif
g_scan_keep_frequency = false;
@ -1120,11 +1115,13 @@ void APP_process(void)
if (g_voice_write_index == 0)
#endif
{
if (g_screen_to_display != DISPLAY_SEARCH &&
g_scan_state_dir != SCAN_STATE_DIR_OFF &&
g_scan_schedule_scan_listen &&
if ((g_current_function == FUNCTION_FOREGROUND ||
g_current_function == FUNCTION_INCOMING) && // TODO: check me
g_screen_to_display != DISPLAY_SEARCH &&
g_scan_state_dir != SCAN_STATE_DIR_OFF &&
g_scan_pause_10ms == 0 &&
!g_ptt_is_pressed)
{ // scanning
{ // RF scanning
if (IS_FREQ_CHANNEL(g_scan_next_channel))
{
@ -1141,9 +1138,8 @@ void APP_process(void)
APP_next_channel(); // switch to next channel
}
g_scan_pause_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
g_scan_schedule_scan_listen = false;
g_scan_pause_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
}
}
@ -1151,11 +1147,8 @@ void APP_process(void)
if (g_voice_write_index == 0)
#endif
{
if (g_css_scan_mode == CSS_SCAN_MODE_SCANNING && g_scan_schedule_scan_listen)
{
if (g_css_scan_mode == CSS_SCAN_MODE_SCANNING && g_scan_pause_10ms == 0)
MENU_SelectNextCode();
g_scan_schedule_scan_listen = false;
}
}
#ifdef ENABLE_NOAA
@ -2383,8 +2376,7 @@ void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction)
APP_next_freq();
}
g_scan_pause_delay_in_10ms = scan_pause_delay_in_2_10ms;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = scan_pause_2_10ms;
g_scan_pause_mode = false;
g_scan_keep_frequency = false;

View File

@ -328,7 +328,7 @@ void DTMF_HandleRequest(void)
}
}
if (g_setting_radio_disabled || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_setting_radio_disabled || g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT)
{ // we've been disabled, or expecting a reply
return;
}

View File

@ -581,7 +581,7 @@ static void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
{
if (g_current_function != FUNCTION_INCOMING ||
g_rx_reception_mode == RX_MODE_NONE ||
g_scan_pause_delay_in_10ms == 0)
g_scan_pause_10ms == 0)
{ // scan is running (not paused)
return;
}
@ -724,10 +724,13 @@ static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t D
uint8_t Channel = g_eeprom.screen_channel[g_eeprom.tx_vfo];
if (!key_pressed && g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_NOT_NOAA_CHANNEL(Channel) && IS_FREQ_CHANNEL(Channel))
{
if (!key_pressed &&
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
IS_NOT_NOAA_CHANNEL(Channel) &&
IS_FREQ_CHANNEL(Channel))
{ // key released in frequency mode
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
if (key_held && !key_pressed && !monitor_was_enabled && g_current_function == FUNCTION_MONITOR)
if (key_held && !monitor_was_enabled && g_current_function == FUNCTION_MONITOR)
{ // re-enable the squelch
APP_start_listening(FUNCTION_RECEIVE, false);
g_monitor_enabled = false;
@ -736,7 +739,6 @@ static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t D
// only update eeprom when the key is released - saves a LOT of wear and tear on the little eeprom
g_flag_save_channel = 1;
//SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, 1);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("save chan\r\n");
@ -813,8 +815,8 @@ static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t D
if (key_held && key_pressed && !monitor_was_enabled)
{ // open the squelch if the user holds the key down
APP_start_listening(FUNCTION_MONITOR, false);
g_monitor_enabled = true;
APP_start_listening(FUNCTION_MONITOR, false);
}
#endif
@ -860,8 +862,7 @@ static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t D
// jump to the next channel
APP_channel_next(false, Direction);
g_scan_pause_delay_in_10ms = 1;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = 0;
g_ptt_was_released = true;
}

View File

@ -87,8 +87,7 @@ void MENU_StartCssScan(int8_t Direction)
MENU_SelectNextCode();
g_scan_pause_delay_in_10ms = scan_pause_delay_in_2_10ms;
g_scan_schedule_scan_listen = false;
g_scan_pause_10ms = scan_pause_2_10ms;
}
void MENU_StopCssScan(void)
@ -883,7 +882,7 @@ void MENU_SelectNextCode(void)
RADIO_setup_registers(true);
g_scan_pause_delay_in_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_delay_in_3_10ms : scan_pause_delay_in_4_10ms;
g_scan_pause_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_3_10ms : scan_pause_4_10ms;
g_update_display = true;
}

Binary file not shown.

Binary file not shown.

View File

@ -260,7 +260,7 @@ void FUNCTION_Select(function_type_t Function)
break;
case FUNCTION_BAND_SCOPE:
case FUNCTION_PANADAPTER:
break;
}

View File

@ -21,13 +21,13 @@
enum function_type_e
{
FUNCTION_FOREGROUND = 0, // idle (not in power save)
FUNCTION_FOREGROUND = 0, // idle, scanning
FUNCTION_TRANSMIT, // transmitting
FUNCTION_MONITOR, // receiving with squelch forced open
FUNCTION_INCOMING, // receiving a signal (squelch is open)
FUNCTION_INCOMING, // signal just received
FUNCTION_RECEIVE, // RX mode, squelch closed
FUNCTION_POWER_SAVE, // sleeping
FUNCTION_BAND_SCOPE // bandscope mode (panadpter/spectrum) .. not yet implemented
FUNCTION_PANADAPTER // bandscope mode (panadpter/spectrum) .. not yet implemented
};
typedef enum function_type_e function_type_t;

17
misc.c
View File

@ -63,13 +63,13 @@ const uint16_t dual_watch_count_noaa_10ms = 70 / 10; // 70ms
#endif
const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles
const uint16_t scan_pause_delay_in_1_10ms = 5000 / 10; // 5 seconds
const uint16_t scan_pause_delay_in_2_10ms = 500 / 10; // 500ms
const uint16_t scan_pause_delay_in_3_10ms = 200 / 10; // 200ms
const uint16_t scan_pause_delay_in_4_10ms = 300 / 10; // 300ms
const uint16_t scan_pause_delay_in_5_10ms = 1000 / 10; // 1 sec
const uint16_t scan_pause_delay_in_6_10ms = 100 / 10; // 100ms
const uint16_t scan_pause_delay_in_7_10ms = 3600 / 10; // 3.6 seconds
const uint16_t scan_pause_1_10ms = 5000 / 10; // 5 seconds
const uint16_t scan_pause_2_10ms = 500 / 10; // 500ms
const uint16_t scan_pause_3_10ms = 200 / 10; // 200ms
const uint16_t scan_pause_4_10ms = 300 / 10; // 300ms
const uint16_t scan_pause_5_10ms = 1000 / 10; // 1 sec
const uint16_t scan_pause_6_10ms = 100 / 10; // 100ms
const uint16_t scan_pause_7_10ms = 3600 / 10; // 3.6 seconds
const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds
@ -223,8 +223,7 @@ scan_next_chan_t g_scan_current_scan_list;
uint32_t g_scan_restore_frequency;
bool g_scan_keep_frequency;
bool g_scan_pause_mode;
volatile bool g_scan_schedule_scan_listen = true;
volatile uint16_t g_scan_pause_delay_in_10ms;
volatile uint16_t g_scan_pause_10ms;
scan_state_dir_t g_scan_state_dir;
bool g_rx_vfo_is_active;

17
misc.h
View File

@ -161,13 +161,13 @@ extern const uint16_t dual_watch_count_noaa_10ms;
extern const uint16_t dual_watch_count_after_vox_10ms;
#endif
extern const uint16_t scan_pause_delay_in_1_10ms;
extern const uint16_t scan_pause_delay_in_2_10ms;
extern const uint16_t scan_pause_delay_in_3_10ms;
extern const uint16_t scan_pause_delay_in_4_10ms;
extern const uint16_t scan_pause_delay_in_5_10ms;
extern const uint16_t scan_pause_delay_in_6_10ms;
extern const uint16_t scan_pause_delay_in_7_10ms;
extern const uint16_t scan_pause_1_10ms;
extern const uint16_t scan_pause_2_10ms;
extern const uint16_t scan_pause_3_10ms;
extern const uint16_t scan_pause_4_10ms;
extern const uint16_t scan_pause_5_10ms;
extern const uint16_t scan_pause_6_10ms;
extern const uint16_t scan_pause_7_10ms;
extern const uint8_t g_mic_gain_dB_2[5];
@ -303,8 +303,7 @@ extern scan_next_chan_t g_scan_current_scan_list;
extern uint32_t g_scan_restore_frequency;
extern bool g_scan_keep_frequency;
extern bool g_scan_pause_mode;
extern volatile bool g_scan_schedule_scan_listen;
extern volatile uint16_t g_scan_pause_delay_in_10ms;
extern volatile uint16_t g_scan_pause_10ms;
extern scan_state_dir_t g_scan_state_dir;

View File

@ -91,7 +91,7 @@ void SystickHandler(void)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode == CSS_SCAN_MODE_SCANNING)
if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT)
DECREMENT_AND_TRIGGER(g_scan_pause_delay_in_10ms, g_scan_schedule_scan_listen);
DECREMENT(g_scan_pause_10ms);
DECREMENT_AND_TRIGGER(g_tail_tone_elimination_count_down_10ms, g_flag_tail_tone_elimination_complete);