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

fix RF scanning for the different modes (time, carrier & search)

This commit is contained in:
OneOfEleven 2023-10-23 15:52:08 +01:00
parent 7f91f7349b
commit 35ba988657
6 changed files with 91 additions and 74 deletions

View File

@ -90,10 +90,7 @@ void ACTION_Monitor(void)
g_monitor_enabled = false; g_monitor_enabled = false;
if (g_scan_state_dir != SCAN_STATE_DIR_OFF) if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50; g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_mode = true;
}
#ifdef g_power_save_expired #ifdef g_power_save_expired
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode) if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode)
@ -200,7 +197,9 @@ void ACTION_Scan(bool bRestart)
// jump to the next channel // jump to the next channel
APP_channel_next(true, g_scan_state_dir); APP_channel_next(true, g_scan_state_dir);
g_scan_pause_10ms = 0; g_scan_pause_10ms = 0;
g_scan_pause_time_mode = false;
g_update_status = true; g_update_status = true;
return; return;
@ -226,6 +225,7 @@ void ACTION_Scan(bool bRestart)
APP_channel_next(true, SCAN_STATE_DIR_FORWARD); APP_channel_next(true, SCAN_STATE_DIR_FORWARD);
g_scan_pause_10ms = 0; // go NOW g_scan_pause_10ms = 0; // go NOW
g_scan_pause_time_mode = false;
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN); AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
@ -254,7 +254,9 @@ void ACTION_Scan(bool bRestart)
// jump to the next channel // jump to the next channel
APP_channel_next(true, g_scan_state_dir); APP_channel_next(true, g_scan_state_dir);
g_scan_pause_10ms = 0; g_scan_pause_10ms = 0;
g_scan_pause_time_mode = false;
g_update_status = true; g_update_status = true;
} }

109
app/app.c
View File

@ -104,6 +104,7 @@ static void APP_check_for_new_receive(void)
{ // CTCSS/DTS scanning { // CTCSS/DTS scanning
g_scan_pause_10ms = scan_pause_code_10ms; g_scan_pause_10ms = scan_pause_code_10ms;
g_scan_pause_time_mode = false;
g_rx_reception_mode = RX_MODE_DETECTED; g_rx_reception_mode = RX_MODE_DETECTED;
} }
@ -127,6 +128,7 @@ static void APP_check_for_new_receive(void)
goto done; goto done;
g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50; g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_time_mode = false;
g_update_status = true; g_update_status = true;
} }
@ -136,6 +138,7 @@ static void APP_check_for_new_receive(void)
goto done; goto done;
g_scan_pause_10ms = scan_pause_chan_10ms; g_scan_pause_10ms = scan_pause_chan_10ms;
g_scan_pause_time_mode = false;
} }
g_rx_reception_mode = RX_MODE_DETECTED; g_rx_reception_mode = RX_MODE_DETECTED;
@ -225,7 +228,7 @@ static void APP_process_new_receive(void)
} }
enum end_of_rx_mode_e { enum end_of_rx_mode_e {
END_OF_RX_MODE_SKIP = 0, END_OF_RX_MODE_NONE = 0,
END_OF_RX_MODE_END, END_OF_RX_MODE_END,
END_OF_RX_MODE_TTE END_OF_RX_MODE_TTE
}; };
@ -233,7 +236,7 @@ typedef enum end_of_rx_mode_e end_of_rx_mode_t;
static void APP_process_rx(void) static void APP_process_rx(void)
{ {
end_of_rx_mode_t Mode = END_OF_RX_MODE_SKIP; end_of_rx_mode_t Mode = END_OF_RX_MODE_NONE;
if (g_flag_tail_tone_elimination_complete) if (g_flag_tail_tone_elimination_complete)
{ {
@ -241,15 +244,16 @@ static void APP_process_rx(void)
goto Skip; goto Skip;
} }
if (g_scan_state_dir != SCAN_STATE_DIR_OFF && IS_FREQ_CHANNEL(g_scan_next_channel)) // why does being a VFO make a difference ??? .. 1of11
//
/* if (g_scan_state_dir != SCAN_STATE_DIR_OFF && IS_FREQ_CHANNEL(g_scan_next_channel))
{ {
if (g_squelch_open) // return;
return;
Mode = END_OF_RX_MODE_END; Mode = END_OF_RX_MODE_END;
goto Skip; goto Skip;
} }
*/
switch (g_current_code_type) switch (g_current_code_type)
{ {
default: default:
@ -345,7 +349,7 @@ static void APP_process_rx(void)
} }
if (!g_end_of_rx_detected_maybe && if (!g_end_of_rx_detected_maybe &&
Mode == END_OF_RX_MODE_SKIP && Mode == END_OF_RX_MODE_NONE &&
g_next_time_slice_40ms && g_next_time_slice_40ms &&
g_eeprom.tail_note_elimination && g_eeprom.tail_note_elimination &&
(g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL) && (g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL) &&
@ -361,7 +365,7 @@ static void APP_process_rx(void)
Skip: Skip:
switch (Mode) switch (Mode)
{ {
case END_OF_RX_MODE_SKIP: case END_OF_RX_MODE_NONE:
break; break;
case END_OF_RX_MODE_END: case END_OF_RX_MODE_END:
@ -374,26 +378,10 @@ Skip:
g_update_display = true; g_update_display = true;
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{
switch (g_eeprom.scan_resume_mode)
{
case SCAN_RESUME_TIME:
break;
case SCAN_RESUME_CARRIER:
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
break;
case SCAN_RESUME_SEARCH:
APP_stop_scan();
break;
}
}
break; break;
case END_OF_RX_MODE_TTE: case END_OF_RX_MODE_TTE:
if (g_eeprom.tail_note_elimination) if (g_eeprom.tail_note_elimination)
{ {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
@ -403,8 +391,26 @@ Skip:
g_end_of_rx_detected_maybe = true; g_end_of_rx_detected_maybe = true;
g_speaker_enabled = false; g_speaker_enabled = false;
} }
break; break;
} }
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{ // we're RF scanning
switch (g_eeprom.scan_resume_mode)
{
case SCAN_RESUME_TIME: // stay only for a limited time
break;
case SCAN_RESUME_CARRIER: // stay till the carrier goes away
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_time_mode = false;
break;
case SCAN_RESUME_SEARCH:
APP_stop_scan();
break;
}
}
} }
static void APP_process_function(void) static void APP_process_function(void)
@ -445,14 +451,14 @@ static void APP_process_function(void)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
} }
void APP_start_listening(function_type_t Function, const bool reset_am_fix) bool APP_start_listening(function_type_t Function, const bool reset_am_fix)
{ {
const unsigned int chan = g_eeprom.rx_vfo; const unsigned int chan = g_eeprom.rx_vfo;
// const unsigned int chan = g_rx_vfo->channel_save; // const unsigned int chan = g_rx_vfo->channel_save;
#ifdef ENABLE_KILL_REVIVE #ifdef ENABLE_KILL_REVIVE
if (g_setting_radio_disabled) if (g_setting_radio_disabled)
return; return false;
#endif #endif
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
@ -480,17 +486,19 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
switch (g_eeprom.scan_resume_mode) switch (g_eeprom.scan_resume_mode)
{ {
case SCAN_RESUME_TIME: case SCAN_RESUME_TIME:
if (!g_scan_pause_mode) if (!g_scan_pause_time_mode)
{ {
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50; g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_mode = true; g_scan_pause_time_mode = true;
} }
break; break;
case SCAN_RESUME_CARRIER: case SCAN_RESUME_CARRIER:
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_time_mode = false;
break;
case SCAN_RESUME_SEARCH: case SCAN_RESUME_SEARCH:
g_scan_pause_10ms = 0; g_scan_pause_10ms = 0;
g_scan_pause_time_mode = false;
break; break;
} }
@ -515,7 +523,7 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
g_css_scan_mode == CSS_SCAN_MODE_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF &&
g_eeprom.dual_watch != DUAL_WATCH_OFF) g_eeprom.dual_watch != DUAL_WATCH_OFF)
{ // not scanning, but dual watch is enabled { // dual watch is active
g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50; g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_rx_vfo_is_active = true; g_rx_vfo_is_active = true;
@ -578,6 +586,8 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
g_update_display = true; g_update_display = true;
g_update_status = true; g_update_status = true;
return true;
} }
uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step) uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step)
@ -617,13 +627,12 @@ void APP_stop_scan(void)
g_scan_state_dir = SCAN_STATE_DIR_OFF; g_scan_state_dir = SCAN_STATE_DIR_OFF;
// 1of11 // 1of11
if (g_scan_pause_mode || if (g_scan_pause_time_mode ||
g_scan_pause_10ms > (200 / 10) || g_scan_pause_10ms > (200 / 10) ||
g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_RECEIVE ||
g_current_function == FUNCTION_MONITOR || g_current_function == FUNCTION_MONITOR ||
g_current_function == FUNCTION_NEW_RECEIVE) g_current_function == FUNCTION_NEW_RECEIVE)
{ // stay where we are { // stay where we are
g_scan_pause_mode = false;
g_scan_restore_channel = 0xff; g_scan_restore_channel = 0xff;
g_scan_restore_frequency = 0xffffffff; g_scan_restore_frequency = 0xffffffff;
} }
@ -675,6 +684,9 @@ void APP_stop_scan(void)
g_another_voice_id = VOICE_ID_SCANNING_STOP; g_another_voice_id = VOICE_ID_SCANNING_STOP;
#endif #endif
g_scan_pause_10ms = 0;
g_scan_pause_time_mode = false;
g_update_status = true; g_update_status = true;
} }
@ -714,6 +726,7 @@ static void APP_next_freq(void)
#endif #endif
} }
g_scan_pause_time_mode = false;
g_update_display = true; g_update_display = true;
} }
@ -813,6 +826,8 @@ static void APP_next_channel(void)
g_scan_pause_10ms = scan_pause_chan_10ms; g_scan_pause_10ms = scan_pause_chan_10ms;
#endif #endif
g_scan_pause_time_mode = false;
if (enabled) if (enabled)
if (++g_scan_current_scan_list >= SCAN_NEXT_NUM) if (++g_scan_current_scan_list >= SCAN_NEXT_NUM)
g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; // back round we go g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; // back round we go
@ -1133,7 +1148,9 @@ void APP_process(void)
if (g_voice_write_index == 0) if (g_voice_write_index == 0)
#endif #endif
{ {
if ((g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_NEW_RECEIVE) && // TODO: check me if ((g_current_function == FUNCTION_FOREGROUND ||
g_current_function == FUNCTION_NEW_RECEIVE ||
g_current_function == FUNCTION_RECEIVE) &&
g_screen_to_display != DISPLAY_SEARCH && g_screen_to_display != DISPLAY_SEARCH &&
g_scan_state_dir != SCAN_STATE_DIR_OFF && g_scan_state_dir != SCAN_STATE_DIR_OFF &&
g_scan_pause_10ms == 0 && g_scan_pause_10ms == 0 &&
@ -1141,31 +1158,33 @@ void APP_process(void)
{ // RF scanning { // RF scanning
// TODO: check to see if signal stays present for minimum time before pausing // TODO: check to see if signal stays present for minimum time before pausing (debounce)
/*
if (IS_FREQ_CHANNEL(g_scan_next_channel)) if (IS_FREQ_CHANNEL(g_scan_next_channel))
{ { // frequency mode
if (g_current_function == FUNCTION_NEW_RECEIVE)
if (g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode)
{ {
APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
} }
else else
{ // switch to next frequency { // switch to next frequency
g_scan_pause_mode = false; g_scan_pause_time_mode = false;
g_rx_reception_mode = RX_MODE_NONE; g_rx_reception_mode = RX_MODE_NONE;
APP_next_freq(); APP_next_freq();
} }
} }
else else
{ */ { // channel mode
if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE)
if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE && !g_scan_pause_time_mode)
{ {
APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
} }
else else
{ // switch to next channel { // switch to next channel
g_scan_pause_mode = false; g_scan_pause_time_mode = false;
g_rx_reception_mode = RX_MODE_NONE; g_rx_reception_mode = RX_MODE_NONE;
APP_next_channel(); APP_next_channel();
} }
@ -1220,7 +1239,6 @@ void APP_process(void)
GUI_SelectNextDisplay(DISPLAY_MAIN); GUI_SelectNextDisplay(DISPLAY_MAIN);
g_rx_vfo_is_active = false; g_rx_vfo_is_active = false;
g_scan_pause_mode = false;
g_rx_reception_mode = RX_MODE_NONE; g_rx_reception_mode = RX_MODE_NONE;
} }
@ -2421,8 +2439,7 @@ void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction)
} }
g_scan_pause_10ms = scan_pause_css_10ms; g_scan_pause_10ms = scan_pause_css_10ms;
g_scan_pause_mode = false; g_scan_pause_time_mode = false;
g_rx_reception_mode = RX_MODE_NONE; g_rx_reception_mode = RX_MODE_NONE;
} }

View File

@ -31,7 +31,7 @@ extern const uint8_t orig_pga;
void APP_end_tx(void); void APP_end_tx(void);
void APP_stop_scan(void); void APP_stop_scan(void);
void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction); void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction);
void APP_start_listening(function_type_t Function, const bool reset_am_fix); bool APP_start_listening(function_type_t Function, const bool reset_am_fix);
uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step); uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step);
void APP_process(void); void APP_process(void);
void APP_time_slice_10ms(void); void APP_time_slice_10ms(void);

View File

@ -43,9 +43,7 @@
bool scanning_paused(void) bool scanning_paused(void)
{ {
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) && if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) &&
g_scan_pause_10ms > 0 && g_scan_pause_10ms > 0 && g_scan_pause_10ms <= (200 / 10))
g_scan_pause_10ms <= (200 / 10) &&
!g_scan_pause_mode)
{ // scanning isn't paused { // scanning isn't paused
return false; return false;
} }

2
misc.c
View File

@ -227,7 +227,7 @@ uint8_t g_scan_next_channel;
scan_next_chan_t g_scan_current_scan_list; scan_next_chan_t g_scan_current_scan_list;
uint8_t g_scan_restore_channel; uint8_t g_scan_restore_channel;
uint32_t g_scan_restore_frequency; uint32_t g_scan_restore_frequency;
bool g_scan_pause_mode; bool g_scan_pause_time_mode; // set if we stopped in SCAN_RESUME_TIME mode
volatile uint16_t g_scan_pause_10ms; volatile uint16_t g_scan_pause_10ms;
scan_state_dir_t g_scan_state_dir; scan_state_dir_t g_scan_state_dir;

2
misc.h
View File

@ -310,7 +310,7 @@ extern uint8_t g_scan_next_channel; //
extern scan_next_chan_t g_scan_current_scan_list; // extern scan_next_chan_t g_scan_current_scan_list; //
extern uint8_t g_scan_restore_channel; // the channel we were on before starting the RF scan extern uint8_t g_scan_restore_channel; // the channel we were on before starting the RF scan
extern uint32_t g_scan_restore_frequency; // the frequency we were on before starting the RF scan extern uint32_t g_scan_restore_frequency; // the frequency we were on before starting the RF scan
extern bool g_scan_pause_mode; // set if we're paused on a channel or frequency ? extern bool g_scan_pause_time_mode; // set if we stopped in SCAN_RESUME_TIME mode
extern volatile uint16_t g_scan_pause_10ms; // ticks till we move to next channel/frequency extern volatile uint16_t g_scan_pause_10ms; // ticks till we move to next channel/frequency
extern scan_state_dir_t g_scan_state_dir; // the direction we're scanning in extern scan_state_dir_t g_scan_state_dir; // the direction we're scanning in