mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 22:58:04 +03:00
Can now interrupt RF scanning with any other function
This commit is contained in:
@ -90,8 +90,8 @@ void ACTION_Monitor(void)
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
{
|
||||
g_scan_pause_10ms = scan_pause_1_10ms;
|
||||
g_scan_pause_mode = true;
|
||||
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_mode = true;
|
||||
}
|
||||
|
||||
#ifdef g_power_save_expired
|
||||
|
241
app/app.c
241
app/app.c
@ -103,7 +103,7 @@ 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_10ms = scan_pause_5_10ms;
|
||||
g_scan_pause_10ms = scan_pause_code_10ms;
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
}
|
||||
|
||||
@ -118,62 +118,32 @@ static void APP_check_for_incoming_rx(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_current_function != FUNCTION_INCOMING)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//g_update_display = true;
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
g_update_rssi = true;
|
||||
}
|
||||
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
|
||||
// dual watch is enabled and we're RX'ing a signal
|
||||
|
||||
if (g_rx_reception_mode != RX_MODE_NONE)
|
||||
{
|
||||
if (g_current_function != FUNCTION_INCOMING)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//g_update_display = true;
|
||||
goto done;
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
g_update_rssi = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
g_dual_watch_count_down_10ms = dual_watch_count_after_rx_10ms;
|
||||
g_schedule_dual_watch = false;
|
||||
g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
else
|
||||
{ // RF scanning
|
||||
if (g_rx_reception_mode != RX_MODE_NONE)
|
||||
{
|
||||
if (g_current_function != FUNCTION_INCOMING)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//g_update_display = true;
|
||||
goto done;
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
g_update_rssi = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
g_scan_pause_10ms = scan_pause_3_10ms;
|
||||
g_scan_pause_10ms = scan_pause_chan_10ms;
|
||||
}
|
||||
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
|
||||
done:
|
||||
if (g_current_function != FUNCTION_INCOMING)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_INCOMING);
|
||||
//g_update_display = true;
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
g_update_rssi = true;
|
||||
@ -223,7 +193,7 @@ static void APP_process_incoming_rx(void)
|
||||
return;
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{ // not scanning
|
||||
{ // not code scanning
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
|
||||
@ -238,10 +208,8 @@ static void APP_process_incoming_rx(void)
|
||||
{
|
||||
if (g_rx_reception_mode == RX_MODE_DETECTED)
|
||||
{
|
||||
g_dual_watch_count_down_10ms = dual_watch_count_after_1_10ms;
|
||||
g_schedule_dual_watch = false;
|
||||
|
||||
g_rx_reception_mode = RX_MODE_LISTENING;
|
||||
g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_rx_reception_mode = RX_MODE_LISTENING;
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
@ -411,7 +379,7 @@ Skip:
|
||||
break;
|
||||
|
||||
case SCAN_RESUME_CO:
|
||||
g_scan_pause_10ms = scan_pause_7_10ms;
|
||||
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
break;
|
||||
|
||||
case SCAN_RESUME_SE:
|
||||
@ -456,13 +424,9 @@ static void APP_process_function(void)
|
||||
APP_process_incoming_rx();
|
||||
|
||||
case FUNCTION_MONITOR:
|
||||
if (g_setting_backlight_on_tx_rx >= 2)
|
||||
backlight_turn_on(backlight_tx_rx_time_500ms);
|
||||
break;
|
||||
|
||||
case FUNCTION_RECEIVE:
|
||||
if (g_setting_backlight_on_tx_rx >= 2)
|
||||
backlight_turn_on(backlight_tx_rx_time_500ms);
|
||||
APP_process_rx();
|
||||
break;
|
||||
|
||||
@ -488,6 +452,9 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (g_setting_backlight_on_tx_rx >= 2)
|
||||
backlight_turn_on(backlight_tx_rx_time_500ms);
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (g_fm_radio_mode)
|
||||
BK1080_Init(0, false);
|
||||
@ -501,15 +468,15 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
|
||||
g_enable_speaker = true;
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
{ // we're scanning
|
||||
{ // we're RF scanning
|
||||
|
||||
switch (g_eeprom.scan_resume_mode)
|
||||
{
|
||||
case SCAN_RESUME_TO:
|
||||
if (!g_scan_pause_mode)
|
||||
{
|
||||
g_scan_pause_10ms = scan_pause_1_10ms;
|
||||
g_scan_pause_mode = true;
|
||||
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_mode = true;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -519,7 +486,9 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
|
||||
break;
|
||||
}
|
||||
|
||||
g_scan_keep_frequency = true;
|
||||
g_scan_restore_channel = 0xff;
|
||||
g_scan_restore_frequency = 0;
|
||||
// g_scan_keep_frequency = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
@ -542,10 +511,8 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
|
||||
g_eeprom.dual_watch != DUAL_WATCH_OFF)
|
||||
{ // not scanning, but dual watch is enabled
|
||||
|
||||
g_dual_watch_count_down_10ms = dual_watch_count_after_2_10ms;
|
||||
g_schedule_dual_watch = false;
|
||||
|
||||
g_rx_vfo_is_active = true;
|
||||
g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_rx_vfo_is_active = true;
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
@ -562,16 +529,12 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
|
||||
if (g_rx_vfo->am_mode && g_setting_am_fix)
|
||||
{ // AM RX mode
|
||||
if (reset_am_fix)
|
||||
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency .. or do we ???
|
||||
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency .. or do we ???
|
||||
AM_fix_10ms(chan);
|
||||
}
|
||||
else
|
||||
{ // FM RX mode
|
||||
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
|
||||
}
|
||||
#else
|
||||
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
|
||||
#endif
|
||||
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
|
||||
}
|
||||
|
||||
// AF gain - original QS values
|
||||
@ -599,7 +562,7 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
|
||||
#else
|
||||
if (Function == FUNCTION_MONITOR)
|
||||
#endif
|
||||
{ // squelch is disabled
|
||||
{ // monitor mode (open squelch)
|
||||
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
}
|
||||
@ -637,46 +600,53 @@ uint32_t APP_set_frequency_by_step(vfo_info_t *pInfo, int8_t Step)
|
||||
|
||||
void APP_stop_scan(void)
|
||||
{
|
||||
const uint8_t Previous = g_scan_restore_channel;
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF)
|
||||
return; // but, but, we weren't doing anything !
|
||||
|
||||
// yes we were ;)
|
||||
|
||||
g_scan_state_dir = SCAN_STATE_DIR_OFF;
|
||||
|
||||
if (!g_scan_keep_frequency)
|
||||
{
|
||||
if (g_scan_next_channel <= USER_CHANNEL_LAST)
|
||||
{
|
||||
g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_restore_channel;
|
||||
g_eeprom.screen_channel[g_eeprom.rx_vfo] = Previous;
|
||||
if (g_scan_restore_channel != 0xff || (g_scan_restore_frequency > 0 && g_scan_restore_frequency != 0xffffffff))
|
||||
{ // revert to where we were before starting the scan
|
||||
|
||||
RADIO_ConfigureChannel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
|
||||
if (g_scan_next_channel <= USER_CHANNEL_LAST)
|
||||
{ // we were channel scanning
|
||||
|
||||
if (g_scan_restore_channel != 0xff)
|
||||
{
|
||||
g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_restore_channel;
|
||||
g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_scan_restore_channel;
|
||||
|
||||
RADIO_configure_channel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_setup_registers(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (g_scan_restore_frequency > 0 && g_scan_restore_frequency != 0xffffffff)
|
||||
{
|
||||
g_rx_vfo->freq_config_rx.frequency = g_scan_restore_frequency;
|
||||
|
||||
RADIO_ApplyOffset(g_rx_vfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
RADIO_setup_registers(true);
|
||||
}
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
g_update_display = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_rx_vfo->channel_save > USER_CHANNEL_LAST)
|
||||
else
|
||||
{
|
||||
RADIO_ApplyOffset(g_rx_vfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
SETTINGS_SaveChannel(g_rx_vfo->channel_save, g_eeprom.rx_vfo, g_rx_vfo, 1);
|
||||
return;
|
||||
if (g_rx_vfo->channel_save > USER_CHANNEL_LAST)
|
||||
{
|
||||
RADIO_ApplyOffset(g_rx_vfo);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
SETTINGS_SaveChannel(g_rx_vfo->channel_save, g_eeprom.rx_vfo, g_rx_vfo, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
SETTINGS_SaveVfoIndices();
|
||||
}
|
||||
|
||||
SETTINGS_SaveVfoIndices();
|
||||
|
||||
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
@ -700,7 +670,7 @@ static void APP_next_freq(void)
|
||||
#ifdef ENABLE_FASTER_CHANNEL_SCAN
|
||||
g_scan_pause_10ms = 8; // 80ms
|
||||
#else
|
||||
g_scan_pause_10ms = scan_pause_6_10ms;
|
||||
g_scan_pause_10ms = scan_pause_freq_10ms;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -711,11 +681,11 @@ static void APP_next_freq(void)
|
||||
#ifdef ENABLE_FASTER_CHANNEL_SCAN
|
||||
g_scan_pause_10ms = 10; // 100ms
|
||||
#else
|
||||
g_scan_pause_10ms = scan_pause_6_10ms;
|
||||
g_scan_pause_10ms = scan_pause_freq_10ms;
|
||||
#endif
|
||||
}
|
||||
|
||||
g_scan_keep_frequency = false;
|
||||
// g_scan_keep_frequency = false;
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
@ -803,7 +773,7 @@ static void APP_next_channel(void)
|
||||
g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_next_channel;
|
||||
g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_scan_next_channel;
|
||||
|
||||
RADIO_ConfigureChannel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
g_update_display = true;
|
||||
@ -812,10 +782,10 @@ static void APP_next_channel(void)
|
||||
#ifdef ENABLE_FASTER_CHANNEL_SCAN
|
||||
g_scan_pause_10ms = 9; // 90ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ?
|
||||
#else
|
||||
g_scan_pause_10ms = scan_pause_3_10ms;
|
||||
g_scan_pause_10ms = scan_pause_chan_10ms;
|
||||
#endif
|
||||
|
||||
g_scan_keep_frequency = false;
|
||||
// g_scan_keep_frequency = false;
|
||||
|
||||
if (enabled)
|
||||
if (++g_scan_current_scan_list >= SCAN_NEXT_NUM)
|
||||
@ -832,6 +802,10 @@ static void APP_next_channel(void)
|
||||
|
||||
static void APP_toggle_dual_watch_vfo(void)
|
||||
{
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("dual watch\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
if (g_is_noaa_mode)
|
||||
{
|
||||
@ -856,9 +830,9 @@ static void APP_toggle_dual_watch_vfo(void)
|
||||
RADIO_setup_registers(false);
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
g_dual_watch_count_down_10ms = g_is_noaa_mode ? dual_watch_count_noaa_10ms : dual_watch_count_toggle_10ms;
|
||||
g_dual_watch_delay_10ms = g_is_noaa_mode ? dual_watch_delay_noaa_10ms : dual_watch_delay_toggle_10ms;
|
||||
#else
|
||||
g_dual_watch_count_down_10ms = dual_watch_count_toggle_10ms;
|
||||
g_dual_watch_delay_10ms = dual_watch_delay_toggle_10ms;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -944,16 +918,14 @@ void APP_process_radio_interrupts(void)
|
||||
{
|
||||
if (g_current_function == FUNCTION_POWER_SAVE && !g_rx_idle_mode)
|
||||
{
|
||||
g_power_save_10ms = power_save2_10ms;
|
||||
g_power_save_10ms = power_save2_10ms;
|
||||
g_power_save_expired = false;
|
||||
}
|
||||
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
|
||||
(g_schedule_dual_watch || g_dual_watch_count_down_10ms < dual_watch_count_after_vox_10ms))
|
||||
(g_dual_watch_delay_10ms == 0 || g_dual_watch_delay_10ms < dual_watch_delay_after_vox_10ms))
|
||||
{
|
||||
g_dual_watch_count_down_10ms = dual_watch_count_after_vox_10ms;
|
||||
g_schedule_dual_watch = false;
|
||||
|
||||
g_dual_watch_delay_10ms = dual_watch_delay_after_vox_10ms;
|
||||
g_update_status = true;
|
||||
}
|
||||
}
|
||||
@ -1180,42 +1152,30 @@ void APP_process(void)
|
||||
#endif
|
||||
|
||||
// toggle between the VFO's if dual watch is enabled
|
||||
if (g_screen_to_display != DISPLAY_SEARCH && g_eeprom.dual_watch != DUAL_WATCH_OFF)
|
||||
{
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("dual watch\r\n");
|
||||
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
|
||||
g_dual_watch_delay_10ms == 0 &&
|
||||
!g_ptt_is_pressed &&
|
||||
#ifdef ENABLE_VOICE
|
||||
g_voice_write_index == 0 &&
|
||||
#endif
|
||||
#ifdef ENABLE_FMRADIO
|
||||
!g_fm_radio_mode &&
|
||||
#endif
|
||||
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
|
||||
g_screen_to_display != DISPLAY_SEARCH &&
|
||||
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
|
||||
g_current_function != FUNCTION_POWER_SAVE &&
|
||||
(g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_POWER_SAVE))
|
||||
{
|
||||
APP_toggle_dual_watch_vfo(); // toggle between the two VFO's
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
if (g_voice_write_index == 0)
|
||||
#endif
|
||||
{
|
||||
if (g_schedule_dual_watch)
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
#ifdef ENABLE_FMRADIO
|
||||
if (!g_fm_radio_mode)
|
||||
#endif
|
||||
{
|
||||
if (!g_ptt_is_pressed &&
|
||||
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
|
||||
g_current_function != FUNCTION_POWER_SAVE)
|
||||
{
|
||||
APP_toggle_dual_watch_vfo(); // toggle between the two VFO's
|
||||
if (g_rx_vfo_is_active && g_screen_to_display == DISPLAY_MAIN)
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
|
||||
if (g_rx_vfo_is_active && g_screen_to_display == DISPLAY_MAIN)
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
|
||||
g_rx_vfo_is_active = false;
|
||||
g_scan_pause_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
g_schedule_dual_watch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
g_rx_vfo_is_active = false;
|
||||
g_scan_pause_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
@ -1311,7 +1271,6 @@ void APP_process(void)
|
||||
g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{ // dual watch mode, toggle between the two VFO's
|
||||
APP_toggle_dual_watch_vfo();
|
||||
|
||||
g_update_rssi = false;
|
||||
}
|
||||
|
||||
@ -1599,7 +1558,7 @@ void APP_time_slice_10ms(void)
|
||||
SETTINGS_SaveChannel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_flag_save_channel ? 1 : 0);
|
||||
g_flag_save_channel = false;
|
||||
|
||||
RADIO_ConfigureChannel(g_eeprom.tx_vfo, VFO_CONFIGURE);
|
||||
RADIO_configure_channel(g_eeprom.tx_vfo, VFO_CONFIGURE);
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
GUI_SelectNextDisplay(DISPLAY_MAIN);
|
||||
@ -2179,8 +2138,8 @@ void APP_time_slice_500ms(void)
|
||||
{
|
||||
BK4819_StopScan();
|
||||
|
||||
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(1, VFO_CONFIGURE_RELOAD);
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
}
|
||||
@ -2395,9 +2354,10 @@ void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction)
|
||||
APP_next_freq();
|
||||
}
|
||||
|
||||
g_scan_pause_10ms = scan_pause_2_10ms;
|
||||
g_scan_pause_mode = false;
|
||||
g_scan_keep_frequency = false;
|
||||
g_scan_pause_10ms = scan_pause_css_10ms;
|
||||
g_scan_pause_mode = false;
|
||||
|
||||
// g_scan_keep_frequency = false;
|
||||
|
||||
g_rx_reception_mode = RX_MODE_NONE;
|
||||
}
|
||||
@ -2522,7 +2482,8 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
// if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
{ // FREQ/CTCSS/CDCSS scanning
|
||||
|
||||
if ((Key >= KEY_0 && Key <= KEY_9) || Key == KEY_F)
|
||||
@ -2800,12 +2761,12 @@ Skip:
|
||||
|
||||
if (g_flag_reset_vfos)
|
||||
{
|
||||
RADIO_ConfigureChannel(0, g_vfo_configure_mode);
|
||||
RADIO_ConfigureChannel(1, g_vfo_configure_mode);
|
||||
RADIO_configure_channel(0, g_vfo_configure_mode);
|
||||
RADIO_configure_channel(1, g_vfo_configure_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
RADIO_ConfigureChannel(g_eeprom.tx_vfo, g_vfo_configure_mode);
|
||||
RADIO_configure_channel(g_eeprom.tx_vfo, g_vfo_configure_mode);
|
||||
}
|
||||
|
||||
if (g_request_display_screen == DISPLAY_INVALID)
|
||||
|
@ -158,7 +158,7 @@ void GENERIC_Key_PTT(bool key_pressed)
|
||||
else
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
{ // CTCSS/CDCSS scanning .. stop
|
||||
MENU_StopCssScan();
|
||||
MENU_stop_css_scan();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_SCANNING_STOP;
|
||||
|
467
app/main.c
467
app/main.c
@ -39,12 +39,45 @@
|
||||
// #include "app/spectrum.h"
|
||||
#endif
|
||||
|
||||
static void MAIN_stop_scan(void)
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF)
|
||||
return;
|
||||
|
||||
APP_stop_scan();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_SCANNING_STOP;
|
||||
#endif
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_update_status = true;
|
||||
}
|
||||
|
||||
void toggle_chan_scanlist(void)
|
||||
{ // toggle the selected channels scanlist setting
|
||||
|
||||
if (g_screen_to_display == DISPLAY_SEARCH || !IS_USER_CHANNEL(g_tx_vfo->channel_save))
|
||||
if (g_screen_to_display != DISPLAY_MAIN || !IS_USER_CHANNEL(g_tx_vfo->channel_save))
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_current_function != FUNCTION_FOREGROUND &&
|
||||
g_current_function != FUNCTION_INCOMING &&
|
||||
g_current_function != FUNCTION_MONITOR &&
|
||||
g_current_function != FUNCTION_RECEIVE)
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_scan_pause_10ms > 0 && !g_scan_pause_mode)
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_tx_vfo->scanlist_1_participation)
|
||||
{
|
||||
if (g_tx_vfo->scanlist_2_participation)
|
||||
@ -71,7 +104,7 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
uint8_t Band;
|
||||
uint8_t Vfo = g_eeprom.tx_vfo;
|
||||
|
||||
if (g_screen_to_display == DISPLAY_MENU)
|
||||
if (g_current_function == FUNCTION_TRANSMIT || g_screen_to_display == DISPLAY_MENU)
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
@ -81,6 +114,9 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
{
|
||||
case KEY_0: // FM
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
MAIN_stop_scan();
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
ACTION_FM();
|
||||
#else
|
||||
@ -90,18 +126,19 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
case KEY_1: // BAND
|
||||
|
||||
if (!IS_FREQ_CHANNEL(g_tx_vfo->channel_save))
|
||||
{
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
MAIN_stop_scan();
|
||||
|
||||
Band = g_tx_vfo->band + 1;
|
||||
if (g_setting_350_enable || Band != BAND5_350MHz)
|
||||
{
|
||||
@ -118,13 +155,13 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
break;
|
||||
|
||||
case KEY_2: // A/B
|
||||
|
||||
MAIN_stop_scan();
|
||||
|
||||
if (g_eeprom.cross_vfo_rx_tx == CROSS_BAND_CHAN_A)
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_CHAN_B;
|
||||
else
|
||||
@ -142,12 +179,13 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
g_request_save_settings = 1;
|
||||
g_flag_reconfigure_vfos = true;
|
||||
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
break;
|
||||
|
||||
case KEY_3: // VFO/MR
|
||||
|
||||
MAIN_stop_scan();
|
||||
|
||||
if (g_eeprom.vfo_open && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
{
|
||||
uint8_t Channel;
|
||||
@ -162,8 +200,6 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -180,8 +216,6 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -192,20 +226,20 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
|
||||
case KEY_4: // FC
|
||||
|
||||
g_fkey_pressed = false;
|
||||
g_search_flag_start_scan = true;
|
||||
g_search_single_frequency = false;
|
||||
g_backup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx;
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
|
||||
g_update_status = true;
|
||||
MAIN_stop_scan();
|
||||
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_search_flag_start_scan = true;
|
||||
g_search_single_frequency = false;
|
||||
g_backup_cross_vfo_rx_tx = g_eeprom.cross_vfo_rx_tx;
|
||||
g_eeprom.cross_vfo_rx_tx = CROSS_BAND_OFF;
|
||||
break;
|
||||
|
||||
case KEY_5: // NOAA
|
||||
|
||||
#ifdef ENABLE_NOAA
|
||||
|
||||
MAIN_stop_scan();
|
||||
|
||||
if (IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
{
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom.noaa_channel[g_eeprom.tx_vfo];
|
||||
@ -213,6 +247,7 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
else
|
||||
{
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom.freq_channel[g_eeprom.tx_vfo];
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_FREQUENCY_MODE;
|
||||
#endif
|
||||
@ -226,81 +261,95 @@ static void processFKeyFunction(const key_code_t Key)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
break;
|
||||
|
||||
case KEY_6: // H/M/L
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF)
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
ACTION_Power();
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
break;
|
||||
|
||||
case KEY_7: // VOX
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
MAIN_stop_scan();
|
||||
|
||||
ACTION_Vox();
|
||||
#else
|
||||
toggle_chan_scanlist();
|
||||
#endif
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
break;
|
||||
|
||||
case KEY_8: // R
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF)
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
g_tx_vfo->frequency_reverse = g_tx_vfo->frequency_reverse == false;
|
||||
g_request_save_channel = 1;
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
|
||||
break;
|
||||
|
||||
case KEY_9: // CALL
|
||||
|
||||
if (RADIO_CheckValidChannel(g_eeprom.chan_1_call, false, 0))
|
||||
if (!RADIO_CheckValidChannel(g_eeprom.chan_1_call, false, 0))
|
||||
{
|
||||
g_eeprom.user_channel[Vfo] = g_eeprom.chan_1_call;
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom.chan_1_call;
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
|
||||
AUDIO_SetDigitVoice(1, g_eeprom.chan_1_call + 1);
|
||||
g_another_voice_id = (voice_id_t)0xFE;
|
||||
#endif
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
break;
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
// swap to the CALL channel
|
||||
|
||||
MAIN_stop_scan();
|
||||
|
||||
g_eeprom.user_channel[Vfo] = g_eeprom.chan_1_call;
|
||||
g_eeprom.screen_channel[Vfo] = g_eeprom.chan_1_call;
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
|
||||
AUDIO_SetDigitVoice(1, g_eeprom.chan_1_call + 1);
|
||||
g_another_voice_id = (voice_id_t)0xFE;
|
||||
#endif
|
||||
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
g_update_status = true;
|
||||
g_fkey_pressed = false;
|
||||
g_fkey_pressed = false;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
// if (!g_fm_radio_mode)
|
||||
#endif
|
||||
// g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
// g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
{
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
if (key_held)
|
||||
{ // key held down
|
||||
|
||||
if (key_pressed)
|
||||
{
|
||||
{ // and pressed
|
||||
if (g_screen_to_display == DISPLAY_MAIN)
|
||||
{
|
||||
if (g_input_box_index > 0)
|
||||
{ // delete any inputted chars
|
||||
{ // clear the user box
|
||||
g_input_box_index = 0;
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
}
|
||||
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
|
||||
processFKeyFunction(Key);
|
||||
}
|
||||
@ -311,27 +360,151 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
|
||||
if (key_pressed)
|
||||
{ // key is pressed
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed
|
||||
return; // don't use the key till it's released
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
return; // don't use the key till it's released
|
||||
}
|
||||
|
||||
if (!g_fkey_pressed)
|
||||
{ // F-key wasn't pressed
|
||||
if (g_fkey_pressed)
|
||||
{ // F-key was first pressed
|
||||
processFKeyFunction(Key);
|
||||
|
||||
const uint8_t Vfo = g_eeprom.tx_vfo;
|
||||
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
|
||||
if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // user is entering channel number
|
||||
|
||||
uint16_t Channel;
|
||||
|
||||
if (g_input_box_index != 3)
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t Vfo = g_eeprom.tx_vfo;
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_current_function == FUNCTION_TRANSMIT)
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
// add the digit to the channel/frequency input box
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
|
||||
if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // user is entering channel number
|
||||
|
||||
uint16_t Channel;
|
||||
|
||||
if (g_input_box_index != 3)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
g_input_box_index = 0;
|
||||
|
||||
Channel = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1;
|
||||
|
||||
if (!RADIO_CheckValidChannel(Channel, false, 0))
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[Vfo] = (uint8_t)Channel;
|
||||
g_eeprom.screen_channel[Vfo] = (uint8_t)Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// #ifdef ENABLE_NOAA
|
||||
// if (IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
// #endif
|
||||
if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // user is entering a frequency
|
||||
|
||||
uint32_t Frequency;
|
||||
|
||||
if (g_input_box_index < 6)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
g_input_box_index = 0;
|
||||
|
||||
NUMBER_Get(g_input_box, &Frequency);
|
||||
|
||||
// clamp the frequency entered to some valid value
|
||||
if (Frequency < FREQ_BAND_TABLE[0].lower)
|
||||
{
|
||||
Frequency = FREQ_BAND_TABLE[0].lower;
|
||||
}
|
||||
else
|
||||
if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower)
|
||||
{
|
||||
const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2;
|
||||
Frequency = (Frequency < center) ? BX4819_BAND1.upper : BX4819_BAND2.lower;
|
||||
}
|
||||
else
|
||||
if (Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper)
|
||||
{
|
||||
Frequency = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper;
|
||||
}
|
||||
|
||||
{
|
||||
const frequency_band_t band = FREQUENCY_GetBand(Frequency);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
if (g_tx_vfo->band != band)
|
||||
{
|
||||
g_tx_vfo->band = band;
|
||||
g_eeprom.screen_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||
g_eeprom.freq_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||
|
||||
SETTINGS_SaveVfoIndices();
|
||||
|
||||
RADIO_configure_channel(Vfo, VFO_CONFIGURE_RELOAD);
|
||||
}
|
||||
|
||||
// Frequency += 75; // is this meant to be rounding ?
|
||||
Frequency += g_tx_vfo->step_freq / 2; // no idea, but this is
|
||||
|
||||
Frequency = FREQUENCY_FloorToStep(Frequency, g_tx_vfo->step_freq, FREQ_BAND_TABLE[g_tx_vfo->band].lower);
|
||||
|
||||
if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower)
|
||||
{ // clamp the frequency to the limit
|
||||
const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2;
|
||||
Frequency = (Frequency < center) ? BX4819_BAND1.upper - g_tx_vfo->step_freq : BX4819_BAND2.lower;
|
||||
}
|
||||
|
||||
g_tx_vfo->freq_config_rx.frequency = Frequency;
|
||||
|
||||
g_request_save_channel = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
if (IS_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // user is entering NOAA channel
|
||||
|
||||
uint8_t Channel;
|
||||
|
||||
if (g_input_box_index != 2)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
@ -339,146 +512,27 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
g_input_box_index = 0;
|
||||
|
||||
Channel = ((g_input_box[0] * 100) + (g_input_box[1] * 10) + g_input_box[2]) - 1;
|
||||
|
||||
if (!RADIO_CheckValidChannel(Channel, false, 0))
|
||||
{
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[Vfo] = (uint8_t)Channel;
|
||||
g_eeprom.screen_channel[Vfo] = (uint8_t)Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// #ifdef ENABLE_NOAA
|
||||
// if (IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
// #endif
|
||||
if (IS_FREQ_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // user is entering a frequency
|
||||
|
||||
uint32_t Frequency;
|
||||
|
||||
if (g_input_box_index < 6)
|
||||
|
||||
Channel = (g_input_box[0] * 10) + g_input_box[1];
|
||||
if (Channel >= 1 && Channel <= ARRAY_SIZE(NOAA_FREQUENCY_TABLE))
|
||||
{
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
g_eeprom.noaa_channel[Vfo] = Channel;
|
||||
g_eeprom.screen_channel[Vfo] = Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
|
||||
g_input_box_index = 0;
|
||||
|
||||
NUMBER_Get(g_input_box, &Frequency);
|
||||
|
||||
// clamp the frequency entered to some valid value
|
||||
if (Frequency < FREQ_BAND_TABLE[0].lower)
|
||||
{
|
||||
Frequency = FREQ_BAND_TABLE[0].lower;
|
||||
}
|
||||
else
|
||||
if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower)
|
||||
{
|
||||
const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2;
|
||||
Frequency = (Frequency < center) ? BX4819_BAND1.upper : BX4819_BAND2.lower;
|
||||
}
|
||||
else
|
||||
if (Frequency > FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper)
|
||||
{
|
||||
Frequency = FREQ_BAND_TABLE[ARRAY_SIZE(FREQ_BAND_TABLE) - 1].upper;
|
||||
}
|
||||
|
||||
{
|
||||
const frequency_band_t band = FREQUENCY_GetBand(Frequency);
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
|
||||
if (g_tx_vfo->band != band)
|
||||
{
|
||||
g_tx_vfo->band = band;
|
||||
g_eeprom.screen_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||
g_eeprom.freq_channel[Vfo] = band + FREQ_CHANNEL_FIRST;
|
||||
|
||||
SETTINGS_SaveVfoIndices();
|
||||
|
||||
RADIO_ConfigureChannel(Vfo, VFO_CONFIGURE_RELOAD);
|
||||
}
|
||||
|
||||
// Frequency += 75; // is this meant to be rounding ?
|
||||
Frequency += g_tx_vfo->step_freq / 2; // no idea, but this is
|
||||
|
||||
Frequency = FREQUENCY_FloorToStep(Frequency, g_tx_vfo->step_freq, FREQ_BAND_TABLE[g_tx_vfo->band].lower);
|
||||
|
||||
if (Frequency >= BX4819_BAND1.upper && Frequency < BX4819_BAND2.lower)
|
||||
{ // clamp the frequency to the limit
|
||||
const uint32_t center = (BX4819_BAND1.upper + BX4819_BAND2.lower) / 2;
|
||||
Frequency = (Frequency < center) ? BX4819_BAND1.upper - g_tx_vfo->step_freq : BX4819_BAND2.lower;
|
||||
}
|
||||
|
||||
g_tx_vfo->freq_config_rx.frequency = Frequency;
|
||||
|
||||
g_request_save_channel = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
if (IS_NOAA_CHANNEL(g_tx_vfo->channel_save))
|
||||
{ // user is entering NOAA channel
|
||||
|
||||
uint8_t Channel;
|
||||
|
||||
if (g_input_box_index != 2)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
return;
|
||||
}
|
||||
|
||||
g_input_box_index = 0;
|
||||
|
||||
Channel = (g_input_box[0] * 10) + g_input_box[1];
|
||||
if (Channel >= 1 && Channel <= ARRAY_SIZE(NOAA_FREQUENCY_TABLE))
|
||||
{
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
g_eeprom.noaa_channel[Vfo] = Channel;
|
||||
g_eeprom.screen_channel[Vfo] = Channel;
|
||||
g_request_save_vfo = true;
|
||||
g_vfo_configure_mode = VFO_CONFIGURE_RELOAD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
g_fkey_pressed = false;
|
||||
g_update_status = true;
|
||||
|
||||
processFKeyFunction(Key);
|
||||
#endif
|
||||
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
}
|
||||
|
||||
static void MAIN_Key_EXIT(bool key_pressed, bool key_held)
|
||||
@ -647,11 +701,8 @@ static void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
|
||||
|
||||
static void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
||||
{
|
||||
if (g_current_function == FUNCTION_TRANSMIT)
|
||||
return;
|
||||
|
||||
if (g_input_box_index > 0)
|
||||
{ // entering a frequency or DTMF string
|
||||
{ // entering a channel, frequency or DTMF string
|
||||
|
||||
if (!key_held && key_pressed)
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
@ -671,6 +722,12 @@ static void MAIN_Key_STAR(bool key_pressed, bool key_held)
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_current_function == FUNCTION_TRANSMIT)
|
||||
{ // RF scanning or TX'ing
|
||||
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (key_pressed)
|
||||
{ // just pressed
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
@ -779,7 +836,7 @@ static void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t D
|
||||
}
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF)
|
||||
{ // not scanning
|
||||
{ // not RF scanning
|
||||
|
||||
if (IS_NOT_NOAA_CHANNEL(Channel))
|
||||
{
|
||||
@ -891,9 +948,9 @@ void MAIN_process_key(key_code_t key, bool key_pressed, bool key_held)
|
||||
{
|
||||
DTMF_Append(Character);
|
||||
g_key_input_count_down = key_input_timeout_500ms;
|
||||
g_ptt_was_released = true;
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_request_display_screen = DISPLAY_MAIN;
|
||||
g_ptt_was_released = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
29
app/menu.c
29
app/menu.c
@ -76,7 +76,7 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
void MENU_StartCssScan(int8_t Direction)
|
||||
void MENU_start_css_scan(int8_t Direction)
|
||||
{
|
||||
g_css_scan_mode = CSS_SCAN_MODE_SCANNING;
|
||||
g_update_status = true;
|
||||
@ -87,10 +87,10 @@ void MENU_StartCssScan(int8_t Direction)
|
||||
|
||||
MENU_SelectNextCode();
|
||||
|
||||
g_scan_pause_10ms = scan_pause_2_10ms;
|
||||
g_scan_pause_10ms = scan_pause_css_10ms;
|
||||
}
|
||||
|
||||
void MENU_StopCssScan(void)
|
||||
void MENU_stop_css_scan(void)
|
||||
{
|
||||
g_css_scan_mode = CSS_SCAN_MODE_OFF;
|
||||
g_update_status = true;
|
||||
@ -143,6 +143,11 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
|
||||
*pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1;
|
||||
break;
|
||||
|
||||
case MENU_SCAN_HOLD:
|
||||
*pMin = 2;
|
||||
*pMax = 20;
|
||||
break;
|
||||
|
||||
case MENU_XB:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(g_sub_menu_xb) - 1;
|
||||
@ -557,6 +562,10 @@ void MENU_AcceptSetting(void)
|
||||
g_update_status = true;
|
||||
break;
|
||||
|
||||
case MENU_SCAN_HOLD:
|
||||
g_eeprom.scan_hold_time_500ms = g_sub_menu_selection;
|
||||
break;
|
||||
|
||||
case MENU_XB:
|
||||
if (IS_NOAA_CHANNEL(g_eeprom.screen_channel[0]))
|
||||
return;
|
||||
@ -882,7 +891,7 @@ void MENU_SelectNextCode(void)
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
|
||||
g_scan_pause_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_3_10ms : scan_pause_4_10ms;
|
||||
g_scan_pause_10ms = (g_selected_code_type == CODE_TYPE_CONTINUOUS_TONE) ? scan_pause_ctcss_10ms : scan_pause_cdcss_10ms;
|
||||
|
||||
g_update_display = true;
|
||||
}
|
||||
@ -1022,6 +1031,10 @@ void MENU_ShowCurrentSetting(void)
|
||||
g_sub_menu_selection = (g_eeprom.dual_watch == DUAL_WATCH_OFF) ? 0 : 1;
|
||||
break;
|
||||
|
||||
case MENU_SCAN_HOLD:
|
||||
g_sub_menu_selection = g_eeprom.scan_hold_time_500ms;
|
||||
break;
|
||||
|
||||
case MENU_XB:
|
||||
g_sub_menu_selection = g_eeprom.cross_vfo_rx_tx;
|
||||
break;
|
||||
@ -1482,7 +1495,7 @@ static void MENU_Key_EXIT(bool key_pressed, bool key_held)
|
||||
}
|
||||
else
|
||||
{
|
||||
MENU_StopCssScan();
|
||||
MENU_stop_css_scan();
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_SCANNING_STOP;
|
||||
@ -1669,7 +1682,7 @@ static void MENU_Key_STAR(const bool key_pressed, const bool key_held)
|
||||
|
||||
if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
MENU_StartCssScan(1);
|
||||
MENU_start_css_scan(1);
|
||||
g_request_display_screen = DISPLAY_MENU;
|
||||
#ifdef ENABLE_VOICE
|
||||
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
|
||||
@ -1678,7 +1691,7 @@ static void MENU_Key_STAR(const bool key_pressed, const bool key_held)
|
||||
}
|
||||
else
|
||||
{
|
||||
MENU_StopCssScan();
|
||||
MENU_stop_css_scan();
|
||||
g_request_display_screen = DISPLAY_MENU;
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = VOICE_ID_SCANNING_STOP;
|
||||
@ -1737,7 +1750,7 @@ static void MENU_Key_UP_DOWN(bool key_pressed, bool key_held, int8_t Direction)
|
||||
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
MENU_StartCssScan(Direction);
|
||||
MENU_start_css_scan(Direction);
|
||||
|
||||
g_ptt_was_released = true;
|
||||
g_request_display_screen = DISPLAY_MENU;
|
||||
|
@ -27,8 +27,8 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax);
|
||||
void MENU_AcceptSetting(void);
|
||||
void MENU_SelectNextCode(void);
|
||||
void MENU_ShowCurrentSetting(void);
|
||||
void MENU_StartCssScan(int8_t Direction);
|
||||
void MENU_StopCssScan(void);
|
||||
void MENU_start_css_scan(int8_t Direction);
|
||||
void MENU_stop_css_scan(void);
|
||||
|
||||
void MENU_process_key(key_code_t Key, bool key_pressed, bool key_held);
|
||||
|
||||
|
@ -334,8 +334,8 @@ static void SEARCH_Key_MENU(bool key_pressed, bool key_held)
|
||||
}
|
||||
else
|
||||
{
|
||||
RADIO_ConfigureChannel(0, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_ConfigureChannel(1, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD);
|
||||
RADIO_configure_channel(1, VFO_CONFIGURE_RELOAD);
|
||||
|
||||
g_tx_vfo->freq_config_rx.code_type = g_search_css_result_type;
|
||||
g_tx_vfo->freq_config_rx.code = g_search_css_result_code;
|
||||
|
Reference in New Issue
Block a user