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

Can now interrupt RF scanning with any other function

This commit is contained in:
OneOfEleven 2023-10-17 11:05:41 +01:00
parent 73572f24b1
commit d47cd80fd4
24 changed files with 529 additions and 459 deletions

View File

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

239
app/app.c
View File

@ -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,45 +600,52 @@ 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)

View File

@ -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;

View File

@ -39,11 +39,44 @@
// #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)
{
@ -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_fkey_pressed = false;
g_update_status = true;
return;
}
g_key_input_count_down = key_input_timeout_500ms;
const uint8_t Vfo = g_eeprom.tx_vfo;
INPUTBOX_Append(Key);
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;
}
g_request_display_screen = DISPLAY_MAIN;
// add the digit to the channel/frequency input box
if (IS_USER_CHANNEL(g_tx_vfo->channel_save))
{ // user is entering channel number
INPUTBOX_Append(Key);
uint16_t Channel;
g_request_display_screen = DISPLAY_MAIN;
if (g_input_box_index != 3)
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;
@ -342,143 +515,24 @@ static void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
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
#endif
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);
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;
}

View File

@ -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;

View File

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

View File

@ -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;

View File

@ -99,7 +99,7 @@ const uint8_t BITMAP_RX[8] =
};
#endif
const uint8_t BITMAP_USB_C[9] =
const uint8_t BITMAP_USB_C[8] =
{ // USB symbol
__extension__ 0b00000000,
__extension__ 0b00011100,
@ -107,13 +107,12 @@ const uint8_t BITMAP_USB_C[9] =
__extension__ 0b01000100,
__extension__ 0b01000100,
__extension__ 0b01000100,
__extension__ 0b01000100,
__extension__ 0b00100111,
__extension__ 0b00011100
};
const uint8_t BITMAP_KEYLOCK[6] =
{ // teeny padlock symbol
{ // teeny weeny padlock symbol
__extension__ 0b00000000,
__extension__ 0b01111100,
__extension__ 0b01000110,
@ -191,7 +190,7 @@ const uint8_t BITMAP_F_KEY[6] =
};
#endif
const uint8_t BITMAP_TDR1[12] =
const uint8_t BITMAP_TDR_RUNNING[12] =
{ // "DW"
__extension__ 0b00000000,
__extension__ 0b01111111,
@ -207,20 +206,20 @@ const uint8_t BITMAP_TDR1[12] =
__extension__ 0b01111111
};
const uint8_t BITMAP_TDR2[12] =
{ // "><" .. DW on hold
const uint8_t BITMAP_TDR_HOLDING[12] =
{ // "--" .. DW on hold
__extension__ 0b00000000,
__extension__ 0b00000000,
__extension__ 0b00100010,
__extension__ 0b00110110,
__extension__ 0b00011100,
__extension__ 0b00001000,
__extension__ 0b00001000,
__extension__ 0b00001000,
__extension__ 0b00001000,
__extension__ 0b00001000,
__extension__ 0b00000000,
__extension__ 0b00001000,
__extension__ 0b00011100,
__extension__ 0b00110110,
__extension__ 0b00100010,
__extension__ 0b00000000
__extension__ 0b00001000,
__extension__ 0b00001000,
__extension__ 0b00001000,
__extension__ 0b00001000
};
#ifdef ENABLE_VOICE
@ -238,6 +237,16 @@ const uint8_t BITMAP_TDR2[12] =
};
#endif
const uint8_t BITMAP_MONITOR[6] =
{ // "M"
__extension__ 0b00000000,
__extension__ 0b01111111,
__extension__ 0b00000010,
__extension__ 0b00001100,
__extension__ 0b00000010,
__extension__ 0b01111111
};
#ifdef ENABLE_FMRADIO
const uint8_t BITMAP_FM[12] =
{ // "FM"
@ -247,7 +256,6 @@ const uint8_t BITMAP_TDR2[12] =
__extension__ 0b00001001,
__extension__ 0b00001001,
__extension__ 0b00000001,
__extension__ 0b00000000,
__extension__ 0b01111111,
__extension__ 0b00000010,

View File

@ -10,7 +10,7 @@ extern const uint8_t BITMAP_RX[8];
extern const uint8_t BITMAP_BATTERY_LEVEL[17];
extern const uint8_t BITMAP_USB_C[9];
extern const uint8_t BITMAP_USB_C[8];
extern const uint8_t BITMAP_KEYLOCK[6];
@ -26,13 +26,15 @@ extern const uint8_t BITMAP_F_KEY[6];
extern const uint8_t BITMAP_XB[12];
#endif
extern const uint8_t BITMAP_TDR1[12];
extern const uint8_t BITMAP_TDR2[12];
extern const uint8_t BITMAP_TDR_RUNNING[12];
extern const uint8_t BITMAP_TDR_HOLDING[12];
#ifdef ENABLE_VOICE
extern const uint8_t BITMAP_VOICE_PROMPT[9];
#endif
extern const uint8_t BITMAP_MONITOR[6];
#ifdef ENABLE_FMRADIO
extern const uint8_t BITMAP_FM[12];
#endif

View File

@ -747,6 +747,10 @@ void BOARD_EEPROM_load(void)
#endif
g_setting_backlight_on_tx_rx = (Data[7] >> 6) & 3u;
// 0F48..0F4F
EEPROM_ReadBuffer(0x0F48, Data, 8);
g_eeprom.scan_hold_time_500ms = (Data[0] > 20) ? 6 : (Data[0] < 2) ? 6 : Data[0];
if (!g_eeprom.vfo_open)
{
g_eeprom.screen_channel[0] = g_eeprom.user_channel[0];

Binary file not shown.

Binary file not shown.

View File

@ -89,11 +89,14 @@ void FUNCTION_Select(function_type_t Function)
if (was_power_save && Function != FUNCTION_POWER_SAVE)
{ // wake up
BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable();
g_rx_idle_mode = false;
UI_DisplayStatus(false);
}
g_update_status = true;
switch (Function)
{
case FUNCTION_FOREGROUND:
@ -125,7 +128,6 @@ void FUNCTION_Select(function_type_t Function)
g_dtmf_auto_reset_time_500ms = g_eeprom.dtmf_auto_reset_time * 2;
}
g_update_status = true;
return;
case FUNCTION_MONITOR:
@ -165,8 +167,6 @@ void FUNCTION_Select(function_type_t Function)
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_UNKNOWN, false);
g_update_status = true;
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
GUI_SelectNextDisplay(DISPLAY_MAIN);
@ -258,6 +258,13 @@ void FUNCTION_Select(function_type_t Function)
if (g_setting_backlight_on_tx_rx == 1 || g_setting_backlight_on_tx_rx == 3)
backlight_turn_on(backlight_tx_rx_time_500ms);
if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
{ // dual-RX is enabled
g_dual_watch_delay_10ms = dual_watch_delay_after_tx_10ms;
if (g_dual_watch_delay_10ms < (g_eeprom.scan_hold_time_500ms * 50))
g_dual_watch_delay_10ms = g_eeprom.scan_hold_time_500ms * 50;
}
break;
case FUNCTION_PANADAPTER:
@ -265,9 +272,11 @@ void FUNCTION_Select(function_type_t Function)
}
g_battery_save_count_down_10ms = battery_save_count_10ms;
g_schedule_power_save = false;
g_schedule_power_save = false;
#if defined(ENABLE_FMRADIO)
g_fm_restore_count_down_10ms = 0;
#endif
g_update_status = true;
}

4
main.c
View File

@ -92,8 +92,8 @@ void Main(void)
BOARD_EEPROM_LoadCalibration();
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_select_vfos();

40
misc.c
View File

@ -53,23 +53,19 @@ const uint8_t key_repeat_10ms = 50 / 10; // 50ms
const uint16_t scan_freq_css_timeout_10ms = 10000 / 10; // 10 seconds
const uint8_t scan_freq_css_delay_10ms = 210 / 10; // 210ms .. don't reduce this
const uint16_t dual_watch_count_after_tx_10ms = 3600 / 10; // 3.6 sec after TX ends
const uint16_t dual_watch_count_after_rx_10ms = 1000 / 10; // 1 sec after RX ends ?
const uint16_t dual_watch_count_after_1_10ms = 5000 / 10; // 5 sec
const uint16_t dual_watch_count_after_2_10ms = 3600 / 10; // 3.6 sec
const uint16_t dual_watch_count_noaa_10ms = 70 / 10; // 70ms
#ifdef ENABLE_VOX
const uint16_t dual_watch_count_after_vox_10ms = 200 / 10; // 200ms
const uint16_t dual_watch_delay_after_vox_10ms = 200 / 10; // 200ms
#endif
const uint16_t dual_watch_count_toggle_10ms = 100 / 10; // 100ms between VFO toggles
const uint16_t dual_watch_delay_after_tx_10ms = 7000 / 10; // 7 sec after TX ends
const uint16_t dual_watch_delay_noaa_10ms = 70 / 10; // 70ms
const uint16_t dual_watch_delay_toggle_10ms = 100 / 10; // 100ms between VFO toggles
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 scan_pause_code_10ms = 1000 / 10; // 1 sec
const uint16_t scan_pause_css_10ms = 500 / 10; // 500ms
const uint16_t scan_pause_ctcss_10ms = 200 / 10; // 200ms
const uint16_t scan_pause_cdcss_10ms = 300 / 10; // 300ms
const uint16_t scan_pause_freq_10ms = 100 / 10; // 100ms
const uint16_t scan_pause_chan_10ms = 200 / 10; // 200ms
const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds
@ -80,9 +76,9 @@ const uint16_t power_save2_10ms = 200 / 10; // 200ms
const uint16_t vox_stop_count_down_10ms = 1000 / 10; // 1 second
#endif
const uint16_t noaa_count_down_10ms = 5000 / 10; // 5 seconds
const uint16_t noaa_count_down_2_10ms = 500 / 10; // 500ms
const uint16_t noaa_count_down_3_10ms = 200 / 10; // 200ms
const uint16_t noaa_count_down_10ms = 5000 / 10; // 5 seconds
const uint16_t noaa_count_down_2_10ms = 500 / 10; // 500ms
const uint16_t noaa_count_down_3_10ms = 200 / 10; // 200ms
// ***********************************************
@ -141,10 +137,8 @@ volatile uint16_t g_battery_save_count_down_10ms = battery_save_count_10ms;
volatile bool g_power_save_expired;
volatile bool g_schedule_power_save;
volatile bool g_schedule_dual_watch = true;
volatile uint16_t g_dual_watch_count_down_10ms;
volatile bool g_dual_watch_count_down_expired = true;
volatile uint16_t g_dual_watch_delay_10ms;
volatile bool g_dual_watch_delay_down_expired = true;
volatile uint8_t g_serial_config_count_down_500ms;
@ -221,10 +215,10 @@ uint16_t g_low_batteryCountdown;
reception_mode_t g_rx_reception_mode;
uint8_t g_scan_next_channel;
uint8_t g_scan_restore_channel;
scan_next_chan_t g_scan_current_scan_list;
uint8_t g_scan_restore_channel;
uint32_t g_scan_restore_frequency;
bool g_scan_keep_frequency;
//bool g_scan_keep_frequency;
bool g_scan_pause_mode;
volatile uint16_t g_scan_pause_10ms;
scan_state_dir_t g_scan_state_dir;

46
misc.h
View File

@ -151,23 +151,19 @@ extern const uint16_t noaa_count_down_10ms;
extern const uint16_t noaa_count_down_2_10ms;
extern const uint16_t noaa_count_down_3_10ms;
extern const uint16_t dual_watch_count_after_tx_10ms;
extern const uint16_t dual_watch_count_after_rx_10ms;
extern const uint16_t dual_watch_count_after_1_10ms;
extern const uint16_t dual_watch_count_after_2_10ms;
extern const uint16_t dual_watch_count_toggle_10ms;
extern const uint16_t dual_watch_count_noaa_10ms;
#ifdef ENABLE_VOX
extern const uint16_t dual_watch_count_after_vox_10ms;
extern const uint16_t dual_watch_delay_after_vox_10ms;
#endif
extern const uint16_t dual_watch_delay_after_tx_10ms;
extern const uint16_t dual_watch_delay_toggle_10ms;
extern const uint16_t dual_watch_delay_noaa_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 uint16_t scan_pause_code_10ms;
extern const uint16_t scan_pause_css_10ms;
extern const uint16_t scan_pause_ctcss_10ms;
extern const uint16_t scan_pause_cdcss_10ms;
extern const uint16_t scan_pause_freq_10ms;
extern const uint16_t scan_pause_chan_10ms;
extern const uint8_t g_mic_gain_dB_2[5];
@ -224,10 +220,8 @@ extern volatile uint16_t g_battery_save_count_down_10ms;
extern volatile bool g_power_save_expired;
extern volatile bool g_schedule_power_save;
extern volatile bool g_schedule_dual_watch;
extern volatile uint16_t g_dual_watch_count_down_10ms;
extern volatile bool g_dual_watch_count_down_expired;
extern volatile uint16_t g_dual_watch_delay_10ms;
extern volatile bool g_dual_watch_delay_down_expired;
extern volatile uint8_t g_serial_config_count_down_500ms;
@ -300,14 +294,14 @@ extern bool g_flag_end_tx;
extern uint16_t g_low_batteryCountdown;
extern reception_mode_t g_rx_reception_mode;
extern uint8_t g_scan_next_channel;
extern uint8_t g_scan_restore_channel;
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 uint16_t g_scan_pause_10ms;
extern scan_state_dir_t g_scan_state_dir;
extern uint8_t g_scan_next_channel; //
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 uint32_t g_scan_restore_frequency; // the frequency we were on before starting the RF scan
//extern bool g_scan_keep_frequency;
extern bool g_scan_pause_mode; // set if we're paused on a channel or 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 bool g_rx_vfo_is_active;

22
radio.c
View File

@ -16,6 +16,7 @@
#include <string.h>
#include "app/app.h"
#include "app/dtmf.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
@ -138,7 +139,7 @@ void RADIO_InitInfo(vfo_info_t *pInfo, const uint8_t ChannelSave, const uint32_t
RADIO_ConfigureSquelchAndOutputPower(pInfo);
}
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure)
void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure)
{
uint8_t Channel;
uint8_t Attributes;
@ -621,7 +622,7 @@ void RADIO_select_vfos(void)
RADIO_SelectCurrentVfo();
}
void RADIO_setup_registers(bool switch_to_function_0)
void RADIO_setup_registers(bool switch_to_function_foreground)
{
BK4819_filter_bandwidth_t Bandwidth = g_rx_vfo->channel_bandwidth;
uint16_t interrupt_mask;
@ -653,9 +654,9 @@ void RADIO_setup_registers(bool switch_to_function_0)
#pragma GCC diagnostic pop
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, false); // LED off
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, false); // LED off
BK4819_SetupPowerAmplifier(0, 0);
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1_UNKNOWN, false); // ???
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1_UNKNOWN, false); // ???
while (1)
{ // wait for the interrupt to clear ?
@ -822,8 +823,13 @@ void RADIO_setup_registers(bool switch_to_function_0)
FUNCTION_Init();
if (switch_to_function_0)
FUNCTION_Select(FUNCTION_FOREGROUND);
if (switch_to_function_foreground)
{
if (g_monitor_enabled)
APP_start_listening(FUNCTION_MONITOR, false);
else
FUNCTION_Select(FUNCTION_FOREGROUND);
}
}
#ifdef ENABLE_NOAA
@ -975,10 +981,6 @@ void RADIO_PrepareTX(void)
if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
{ // dual-RX is enabled
g_dual_watch_count_down_10ms = dual_watch_count_after_tx_10ms;
g_schedule_dual_watch = false;
#if 0
if (g_rx_vfo_is_active)
{ // use the TX vfo

View File

@ -129,11 +129,11 @@ extern vfo_state_t g_vfo_state[2];
bool RADIO_CheckValidChannel(uint16_t ChNum, bool bCheckScanList, uint8_t RadioNum);
uint8_t RADIO_FindNextChannel(uint8_t ChNum, scan_state_dir_t Direction, bool bCheckScanList, uint8_t RadioNum);
void RADIO_InitInfo(vfo_info_t *pInfo, const uint8_t ChannelSave, const uint32_t Frequency);
void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure);
void RADIO_configure_channel(const unsigned int VFO, const unsigned int configure);
void RADIO_ConfigureSquelchAndOutputPower(vfo_info_t *pInfo);
void RADIO_ApplyOffset(vfo_info_t *pInfo);
void RADIO_select_vfos(void);
void RADIO_setup_registers(bool switch_to_function_0);
void RADIO_setup_registers(bool switch_to_function_foreground);
#ifdef ENABLE_NOAA
void RADIO_ConfigureNOAA(void);
#endif

View File

@ -78,9 +78,10 @@ void SystickHandler(void)
if (g_current_function == FUNCTION_POWER_SAVE)
DECREMENT_AND_TRIGGER(g_power_save_10ms, g_power_save_expired);
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch != DUAL_WATCH_OFF)
if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(g_dual_watch_count_down_10ms, g_schedule_dual_watch);
if (g_eeprom.dual_watch != DUAL_WATCH_OFF)
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
if (g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_POWER_SAVE)
DECREMENT(g_dual_watch_delay_10ms);
#ifdef ENABLE_NOAA
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF && g_eeprom.dual_watch == DUAL_WATCH_OFF)

View File

@ -329,8 +329,11 @@ void SETTINGS_SaveSettings(void)
if (!g_setting_am_fix) State[7] &= ~(1u << 5);
#endif
State[7] = (State[7] & ~(3u << 6)) | ((g_setting_backlight_on_tx_rx & 3u) << 6);
EEPROM_WriteBuffer(0x0F40, State);
memset(State, 0xFF, sizeof(State));
State[0] = g_eeprom.scan_hold_time_500ms;
EEPROM_WriteBuffer(0x0F48, State);
}
void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const vfo_info_t *pVFO, uint8_t Mode)

View File

@ -404,7 +404,9 @@ typedef struct {
uint8_t am_fix:1; // 1 = RX AM fix
uint8_t backlight_on_tx_rx:2; // 0 = no backlight when TX/RX, 1 = when TX, 2 = when RX, 3 = both RX/TX
uint8_t unused12[8]; // 0xff's
uint8_t scan_hold_time; //
uint8_t unused12[7]; // 0xff's
#endif
// 0x0F50
@ -526,6 +528,8 @@ typedef struct {
uint16_t vox1_threshold;
uint16_t vox0_threshold;
uint8_t scan_hold_time_500ms;
// uint8_t field29_0x26;
// uint8_t field30_0x27;

View File

@ -59,6 +59,7 @@ const t_menu_item g_menu_list[] =
{"Tx TO", VOICE_ID_TRANSMIT_OVER_TIME, MENU_TOT }, // was "TOT"
{"Tx VFO", VOICE_ID_INVALID, MENU_XB }, // was "WX"
{"Dual W", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR"
{"S HOLD", VOICE_ID_INVALID, MENU_SCAN_HOLD },
{"SCRAM", VOICE_ID_SCRAMBLER_ON, MENU_SCR }, // was "SCR"
{"BCL", VOICE_ID_BUSY_LOCKOUT, MENU_BCL },
{"CH SAV", VOICE_ID_MEMORY_CHANNEL, MENU_MEM_CH }, // was "MEM-CH"
@ -853,6 +854,11 @@ void UI_DisplayMenu(void)
strcpy(String, g_sub_menu_off_on[g_sub_menu_selection]);
break;
case MENU_SCAN_HOLD:
strcpy(String, "SCAN HOLD\n");
sprintf(String + strlen(String), "%d.%d sec", g_sub_menu_selection / 2, 5 * (g_sub_menu_selection % 2));
break;
case MENU_XB:
strcpy(String, g_sub_menu_xb[g_sub_menu_selection]);
break;

View File

@ -53,6 +53,7 @@ enum
MENU_TOT,
MENU_XB,
MENU_TDR,
MENU_SCAN_HOLD,
MENU_SCR,
MENU_BCL,
MENU_MEM_CH,

View File

@ -23,6 +23,7 @@
#include "bitmaps.h"
#include "driver/keyboard.h"
#include "driver/st7565.h"
#include "app/dtmf.h"
#include "external/printf/printf.h"
#include "functions.h"
#include "helper/battery.h"
@ -135,19 +136,29 @@ void UI_DisplayStatus(const bool test_display)
// DUAL-WATCH indicator
if (g_eeprom.dual_watch != DUAL_WATCH_OFF || test_display)
{
if (g_scan_state_dir == SCAN_STATE_DIR_OFF ||
g_squelch_lost ||
g_current_function == FUNCTION_INCOMING ||
g_current_function == FUNCTION_MONITOR ||
g_screen_to_display == DISPLAY_SEARCH ||
test_display)
if (g_dual_watch_delay_10ms > dual_watch_delay_toggle_10ms ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
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) ||
g_screen_to_display == DISPLAY_SEARCH)
{
memmove(line + x, BITMAP_TDR1, sizeof(BITMAP_TDR1)); // dual-watch is paused
memmove(line + x, BITMAP_TDR_HOLDING, sizeof(BITMAP_TDR_HOLDING));
}
else
memmove(line + x, BITMAP_TDR2, sizeof(BITMAP_TDR2)); // dual-watch is running
{
memmove(line + x, BITMAP_TDR_RUNNING, sizeof(BITMAP_TDR_RUNNING));
}
x1 = x + sizeof(BITMAP_TDR_RUNNING);
}
x += sizeof(BITMAP_TDR1);
x += sizeof(BITMAP_TDR_RUNNING);
if (g_current_function == FUNCTION_MONITOR)
{
memmove(line + x, BITMAP_MONITOR, sizeof(BITMAP_MONITOR));
x1 = x + sizeof(BITMAP_MONITOR);
}
x += sizeof(BITMAP_MONITOR);
// CROSS-VFO indicator
if (g_eeprom.cross_vfo_rx_tx != CROSS_BAND_OFF || test_display)