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

FM radio updates - faster scanning and gui update, also some renames

This commit is contained in:
OneOfEleven 2023-10-28 14:07:41 +01:00
parent 0082876274
commit 4153389778
36 changed files with 431 additions and 337 deletions

View File

@ -14,14 +14,14 @@ ENABLE_LTO := 1
ENABLE_UART := 1
ENABLE_UART_DEBUG := 1
# AirCopy 2.5 kB
ENABLE_AIRCOPY := 1
ENABLE_AIRCOPY := 0
ENABLE_AIRCOPY_REMEMBER_FREQ := 1
ENABLE_AIRCOPY_RX_REBOOT := 0
# FM Radio 4.2 kB
ENABLE_FMRADIO_64_76 := 0
ENABLE_FMRADIO_76_90 := 0
ENABLE_FMRADIO_68_108 := 0
ENABLE_FMRADIO_76_108 := 0
ENABLE_FMRADIO_875_108 := 0
ENABLE_FMRADIO_875_108 := 1
# NOAA 1.2 kB
ENABLE_NOAA := 0
# Voice 1.7 kB
@ -105,7 +105,7 @@ ifeq ($(ENABLE_LTO),1)
ENABLE_OVERLAY := 0
endif
ifeq ($(filter $(ENABLE_FMRADIO_76_90) $(ENABLE_FMRADIO_68_108) $(ENABLE_FMRADIO_76_108) $(ENABLE_FMRADIO_875_108), 1), 1)
ifeq ($(filter $(ENABLE_FMRADIO_64_76) $(ENABLE_FMRADIO_76_90) $(ENABLE_FMRADIO_76_108) $(ENABLE_FMRADIO_875_108), 1), 1)
ENABLE_FMRADIO := 1
else
ENABLE_FMRADIO := 0
@ -295,12 +295,12 @@ endif
ifeq ($(ENABLE_AIRCOPY_RX_REBOOT),1)
CFLAGS += -DENABLE_AIRCOPY_RX_REBOOT
endif
ifeq ($(ENABLE_FMRADIO_64_76),1)
CFLAGS += -DENABLE_FMRADIO_64_76
endif
ifeq ($(ENABLE_FMRADIO_76_90),1)
CFLAGS += -DENABLE_FMRADIO_76_90
endif
ifeq ($(ENABLE_FMRADIO_68_108),1)
CFLAGS += -DENABLE_FMRADIO_68_108
endif
ifeq ($(ENABLE_FMRADIO_76_108),1)
CFLAGS += -DENABLE_FMRADIO_76_108
endif

View File

@ -45,8 +45,8 @@ ENABLE_UART_DEBUG := 0 just for code debugging, it sends de
ENABLE_AIRCOPY := 1 clone radio-to-radio via RF
ENABLE_AIRCOPY_REMEMBER_FREQ := 1 remember the aircopy frequency
ENABLE_AIRCOPY_RX_REBOOT := 0 auto reboot on an aircopy successful RX completion
ENABLE_FMRADIO_64_76 := 0 enable FM radio 64MHz ~ 76MHz
ENABLE_FMRADIO_76_90 := 0 enable FM radio 76MHz ~ 90MHz
ENABLE_FMRADIO_68_108 := 0 enable FM radio 68MHz ~ 108MHz
ENABLE_FMRADIO_76_108 := 0 enable FM radio 76MHz ~ 108MHz
ENABLE_FMRADIO_875_108 := 1 enable FM radio 87.5MHz ~ 108MHz
ENABLE_NOAA := 0 everything NOAA (only of any use in the USA)

View File

@ -449,7 +449,7 @@
void AM_fix_print_data(const int vfo, char *s)
{
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return;
if (s != NULL && vfo >= 0 && vfo < (int)ARRAY_SIZE(gain_table_index))

View File

@ -71,7 +71,7 @@ void ACTION_Power(void)
g_another_voice_id = VOICE_ID_POWER;
#endif
g_request_display_screen = g_screen_to_display;
g_request_display_screen = g_current_display_screen;
}
void ACTION_Monitor(void)
@ -97,7 +97,7 @@ void ACTION_Monitor(void)
#ifdef g_power_save_expired
if (g_eeprom.dual_watch == DUAL_WATCH_OFF && g_is_noaa_mode)
{
g_noaa_count_down_10ms = noaa_count_down_10ms;
g_noaa_tick_10ms = noaa_tick_10ms;
g_schedule_noaa = false;
}
#endif
@ -112,7 +112,7 @@ void ACTION_Monitor(void)
}
else
#endif
g_request_display_screen = g_screen_to_display;
g_request_display_screen = g_current_display_screen;
}
void ACTION_Scan(bool bRestart)
@ -169,7 +169,7 @@ void ACTION_Scan(bool bRestart)
}
#endif
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
{ // not in freq/ctcss/cdcss search mode
g_monitor_enabled = false;
@ -302,7 +302,7 @@ void ACTION_Scan(bool bRestart)
g_flag_prepare_tx = true;
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
if (g_current_display_screen != DISPLAY_MENU) // 1of11 .. don't close the menu
g_request_display_screen = DISPLAY_MAIN;
}
#endif

View File

@ -73,7 +73,7 @@ uint16_t g_fsk_buffer[AIRCOPY_DATA_PACKET_SIZE / 2];
unsigned int g_fsk_write_index;
uint16_t g_fsk_tx_timeout_10ms;
uint8_t aircopy_send_count_down_10ms;
uint8_t aircopy_send_tick_10ms;
void AIRCOPY_init(void)
{
@ -255,7 +255,7 @@ void AIRCOPY_stop_fsk_tx(void)
g_aircopy_block_number++;
// TX pause/gap time till we start the next packet
aircopy_send_count_down_10ms = 250 / 10; // 250ms
aircopy_send_tick_10ms = 250 / 10; // 250ms
g_update_display = true;
GUI_DisplayScreen();
@ -278,8 +278,8 @@ void AIRCOPY_process_fsk_tx_10ms(void)
if (g_fsk_write_index > 0)
return; // currently RX'ing a packet
if (aircopy_send_count_down_10ms > 0)
if (--aircopy_send_count_down_10ms > 0)
if (aircopy_send_tick_10ms > 0)
if (--aircopy_send_tick_10ms > 0)
return; // not yet time to TX next packet
if (g_aircopy_block_number >= g_aircopy_block_max)
@ -526,7 +526,7 @@ void AIRCOPY_process_fsk_rx_10ms(void)
else
{ // send them the block they want
g_aircopy_block_number = block_num; // go to the block number they want
aircopy_send_count_down_10ms = 0; // TX asap
aircopy_send_tick_10ms = 0; // TX asap
}
}
@ -800,7 +800,7 @@ static void AIRCOPY_Key_MENU(bool key_pressed, bool key_held)
g_aircopy_rx_errors_magic = 0;
g_aircopy_rx_errors_crc = 0;
g_fsk_tx_timeout_10ms = 0;
aircopy_send_count_down_10ms = 0;
aircopy_send_tick_10ms = 0;
g_aircopy_state = AIRCOPY_TX;
g_update_display = true;

231
app/app.c
View File

@ -122,7 +122,7 @@ static void APP_check_for_new_receive(void)
#ifdef ENABLE_NOAA
if (g_is_noaa_mode)
{
g_noaa_count_down_10ms = noaa_count_down_3_10ms;
g_noaa_tick_10ms = noaa_tick_3_10ms;
g_schedule_noaa = false;
}
#endif
@ -192,9 +192,9 @@ static void APP_process_new_receive(void)
flag = (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_current_code_type == CODE_TYPE_NONE);
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_count_down_10ms > 0)
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_tick_10ms > 0)
{
g_noaa_count_down_10ms = 0;
g_noaa_tick_10ms = 0;
flag = true;
}
#endif
@ -291,7 +291,7 @@ static void APP_process_rx(void)
break;
case CODE_TYPE_CONTINUOUS_TONE:
if (g_found_ctcss && g_found_ctcss_count_down_10ms == 0)
if (g_found_ctcss && g_found_ctcss_tick_10ms == 0)
{
g_found_ctcss = false;
g_found_cdcss = false;
@ -302,7 +302,7 @@ static void APP_process_rx(void)
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
if (g_found_cdcss && g_found_cdcss_count_down_10ms == 0)
if (g_found_cdcss && g_found_cdcss_tick_10ms == 0)
{
g_found_ctcss = false;
g_found_cdcss = false;
@ -341,7 +341,7 @@ static void APP_process_rx(void)
if (!g_found_ctcss)
{
g_found_ctcss = true;
g_found_ctcss_count_down_10ms = 100; // 1 sec
g_found_ctcss_tick_10ms = 100; // 1 sec
}
if (g_cxcss_tail_found)
@ -361,7 +361,7 @@ static void APP_process_rx(void)
if (!g_found_cdcss)
{
g_found_cdcss = true;
g_found_cdcss_count_down_10ms = 100; // 1 sec
g_found_cdcss_tick_10ms = 100; // 1 sec
}
if (g_cxcss_tail_found)
@ -406,7 +406,7 @@ Skip:
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save))
g_noaa_count_down_10ms = 3000 / 10; // 3 sec
g_noaa_tick_10ms = 3000 / 10; // 3 sec
#endif
g_update_display = true;
@ -419,7 +419,7 @@ Skip:
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_tail_tone_elimination_count_down_10ms = 20;
g_tail_tone_elimination_tick_10ms = 20;
g_flag_tail_tone_elimination_complete = false;
g_end_of_rx_detected_maybe = true;
g_speaker_enabled = false;
@ -549,7 +549,7 @@ bool APP_start_listening(function_type_t Function)
g_rx_vfo->p_rx->frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel];
g_rx_vfo->p_tx->frequency = NOAA_FREQUENCY_TABLE[g_noaa_channel];
g_eeprom.screen_channel[chan] = g_rx_vfo->channel_save;
g_noaa_count_down_10ms = 5000 / 10; // 5 sec
g_noaa_tick_10ms = 5000 / 10; // 5 sec
g_schedule_noaa = false;
}
#endif
@ -601,7 +601,7 @@ bool APP_start_listening(function_type_t Function)
if (Function == FUNCTION_MONITOR)
#endif
{ // monitor mode (open squelch)
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
if (g_current_display_screen != DISPLAY_MENU) // 1of11 .. don't close the menu
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
else
@ -909,7 +909,7 @@ static void APP_toggle_dual_watch_vfo(void)
void APP_process_radio_interrupts(void)
{
if (g_screen_to_display == DISPLAY_SEARCH)
if (g_current_display_screen == DISPLAY_SEARCH)
return;
while (BK4819_ReadRegister(0x0C) & (1u << 0))
@ -981,6 +981,10 @@ void APP_process_radio_interrupts(void)
if (interrupt_bits & BK4819_REG_02_CTCSS_FOUND)
g_ctcss_lost = false;
#ifdef ENABLE_MDC1200
MDC1200_process_rx(interrupt_bits);
#endif
#ifdef ENABLE_VOX
if (interrupt_bits & BK4819_REG_02_VOX_LOST)
{
@ -1029,10 +1033,6 @@ void APP_process_radio_interrupts(void)
UART_SendText("sq open\r\n");
#endif
}
#ifdef ENABLE_MDC1200
MDC1200_process_rx(interrupt_bits);
#endif
}
}
@ -1095,9 +1095,9 @@ void APP_end_tx(void)
if (g_vox_noise_detected)
{
if (g_vox_lost)
g_vox_stop_count_down_10ms = vox_stop_count_down_10ms;
g_vox_stop_10ms = vox_stop_10ms;
else
if (g_vox_stop_count_down_10ms == 0)
if (g_vox_stop_10ms == 0)
g_vox_noise_detected = false;
if (g_current_function == FUNCTION_TRANSMIT &&
@ -1136,7 +1136,7 @@ void APP_end_tx(void)
if (g_current_function == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_FOREGROUND);
if (g_current_function != FUNCTION_TRANSMIT && g_serial_config_count_down_500ms == 0)
if (g_current_function != FUNCTION_TRANSMIT && g_serial_config_tick_500ms == 0)
{
g_dtmf_reply_state = DTMF_REPLY_NONE;
RADIO_PrepareTX();
@ -1156,7 +1156,7 @@ void APP_process(void)
}
#endif
if (g_current_function == FUNCTION_TRANSMIT && (g_tx_timeout_reached || g_serial_config_count_down_500ms > 0))
if (g_current_function == FUNCTION_TRANSMIT && (g_tx_timeout_reached || g_serial_config_tick_500ms > 0))
{ // transmitter timed out or must de-key
g_tx_timeout_reached = false;
@ -1169,13 +1169,13 @@ void APP_process(void)
GUI_DisplayScreen();
}
if (g_reduced_service || g_serial_config_count_down_500ms > 0)
if (g_reduced_service || g_serial_config_tick_500ms > 0)
return;
APP_process_function();
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0)
if (g_fm_radio_mode && g_fm_radio_tick_500ms > 0)
return;
#endif
@ -1186,7 +1186,7 @@ void APP_process(void)
if ((g_current_function == FUNCTION_FOREGROUND ||
g_current_function == FUNCTION_NEW_RECEIVE ||
g_current_function == FUNCTION_RECEIVE) &&
g_screen_to_display != DISPLAY_SEARCH &&
g_current_display_screen != DISPLAY_SEARCH &&
g_scan_state_dir != SCAN_STATE_DIR_OFF &&
!g_ptt_is_pressed)
{ // RF scanning
@ -1260,7 +1260,7 @@ void APP_process(void)
APP_next_noaa();
RADIO_setup_registers(false);
g_noaa_count_down_10ms = 7; // 70ms
g_noaa_tick_10ms = 7; // 70ms
g_schedule_noaa = false;
}
}
@ -1277,7 +1277,7 @@ void APP_process(void)
!g_fm_radio_mode &&
#endif
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
g_screen_to_display != DISPLAY_SEARCH &&
g_current_display_screen != DISPLAY_SEARCH &&
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
g_current_function != FUNCTION_POWER_SAVE &&
@ -1285,7 +1285,7 @@ void APP_process(void)
{
APP_toggle_dual_watch_vfo(); // toggle between the two VFO's
if (g_rx_vfo_is_active && g_screen_to_display == DISPLAY_MAIN)
if (g_rx_vfo_is_active && g_current_display_screen == DISPLAY_MAIN)
GUI_SelectNextDisplay(DISPLAY_MAIN);
g_rx_vfo_is_active = false;
@ -1321,10 +1321,10 @@ void APP_process(void)
g_eeprom.battery_save == 0 ||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_screen_to_display != DISPLAY_MAIN ||
g_current_display_screen != DISPLAY_MAIN ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE)
{
g_battery_save_count_down_10ms = battery_save_count_10ms;
g_battery_save_tick_10ms = battery_save_count_10ms;
}
else
if ((IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[0]) &&
@ -1335,7 +1335,7 @@ void APP_process(void)
}
else
{
g_battery_save_count_down_10ms = battery_save_count_10ms;
g_battery_save_tick_10ms = battery_save_count_10ms;
}
#else
if (
@ -1347,10 +1347,10 @@ void APP_process(void)
g_eeprom.battery_save == 0 ||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_screen_to_display != DISPLAY_MAIN ||
g_current_display_screen != DISPLAY_MAIN ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE)
{
g_battery_save_count_down_10ms = battery_save_count_10ms;
g_battery_save_tick_10ms = battery_save_count_10ms;
}
else
{
@ -1431,7 +1431,7 @@ void APP_process(void)
// called every 10ms
void APP_check_keys(void)
{
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && (g_serial_config_count_down_500ms == 0) && g_setting_tx_enable;
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && (g_serial_config_tick_500ms == 0) && g_setting_tx_enable;
key_code_t key;
@ -1450,7 +1450,7 @@ void APP_check_keys(void)
#endif
{
#ifdef ENABLE_AIRCOPY
if (!g_ptt_is_pressed && g_screen_to_display != DISPLAY_AIRCOPY)
if (!g_ptt_is_pressed && g_current_display_screen != DISPLAY_AIRCOPY)
#else
if (!g_ptt_is_pressed)
#endif
@ -1504,7 +1504,7 @@ void APP_check_keys(void)
g_boot_counter_10ms = 0; // cancel boot screen/beeps
if (g_serial_config_count_down_500ms > 0)
if (g_serial_config_tick_500ms > 0)
{ // config upload/download in progress
g_key_debounce_press = 0;
g_key_debounce_repeat = 0;
@ -1528,7 +1528,7 @@ void APP_check_keys(void)
#endif
#ifdef ENABLE_AIRCOPY
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
APP_process_key(g_key_prev, false, g_key_held);
else
AIRCOPY_process_key(g_key_prev, false, g_key_held);
@ -1568,7 +1568,7 @@ void APP_check_keys(void)
g_key_prev = key;
#ifdef ENABLE_AIRCOPY
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
APP_process_key(g_key_prev, true, g_key_held);
else
AIRCOPY_process_key(g_key_prev, true, g_key_held);
@ -1593,7 +1593,7 @@ void APP_check_keys(void)
#endif
#ifdef ENABLE_AIRCOPY
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
APP_process_key(g_key_prev, true, g_key_held);
else
AIRCOPY_process_key(g_key_prev, true, g_key_held);
@ -1617,7 +1617,7 @@ void APP_check_keys(void)
#endif
#ifdef ENABLE_AIRCOPY
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
APP_process_key(g_key_prev, true, g_key_held);
else
AIRCOPY_process_key(g_key_prev, true, g_key_held);
@ -1645,9 +1645,44 @@ void APP_time_slice_10ms(void)
UART_HandleCommand();
__enable_irq();
}
if (g_serial_config_tick_500ms > 0)
{ // config upload/download is running
if (g_update_display)
GUI_DisplayScreen();
if (g_update_status)
UI_DisplayStatus(false);
return;
}
#endif
// ***********
#ifdef ENABLE_AIRCOPY
if (g_current_display_screen == DISPLAY_AIRCOPY)
{ // we're in AIRCOPY mode
if (g_aircopy_state == AIRCOPY_TX)
AIRCOPY_process_fsk_tx_10ms();
AIRCOPY_process_fsk_rx_10ms();
APP_check_keys();
if (g_update_display)
GUI_DisplayScreen();
if (g_update_status)
UI_DisplayStatus(false);
return;
}
#endif
#ifdef ENABLE_AM_FIX
// if (g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix)
if (g_rx_vfo->am_mode && g_setting_am_fix)
AM_fix_10ms(g_eeprom.rx_vfo);
#endif
if (g_flag_save_vfo)
{
@ -1667,6 +1702,10 @@ void APP_time_slice_10ms(void)
SETTINGS_save_fm();
g_flag_save_fm = false;
}
if (g_fm_radio_mode && g_current_display_screen == DISPLAY_FM)
if ((g_flash_light_blink_counter % (500 / 10)) == 0) // once every 500ms
g_update_display = true;
#endif
if (g_flag_save_channel)
@ -1680,19 +1719,6 @@ void APP_time_slice_10ms(void)
GUI_SelectNextDisplay(DISPLAY_MAIN);
}
// ***********
if (g_serial_config_count_down_500ms > 0)
{ // config upload/download is running
if (g_update_display)
GUI_DisplayScreen();
if (g_update_status)
UI_DisplayStatus(false);
return;
}
// ***********
#ifdef ENABLE_BOOT_BEEPS
if (g_boot_counter_10ms > 0 && (g_boot_counter_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
@ -1701,35 +1727,6 @@ void APP_time_slice_10ms(void)
if (g_reduced_service)
return;
#ifdef ENABLE_AIRCOPY
if (g_screen_to_display == DISPLAY_AIRCOPY)
{ // we're in AIRCOPY mode
if (g_aircopy_state == AIRCOPY_TX)
AIRCOPY_process_fsk_tx_10ms();
AIRCOPY_process_fsk_rx_10ms();
APP_check_keys();
if (g_update_display)
GUI_DisplayScreen();
if (g_update_status)
UI_DisplayStatus(false);
return;
}
#endif
#ifdef ENABLE_AM_FIX
// if (g_eeprom.vfo_info[g_eeprom.rx_vfo].am_mode && g_setting_am_fix)
if (g_rx_vfo->am_mode && g_setting_am_fix)
{
AM_fix_10ms(g_eeprom.rx_vfo);
}
#endif
if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode)
APP_process_radio_interrupts();
@ -1750,7 +1747,7 @@ void APP_time_slice_10ms(void)
// Skipping authentic device checks
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_radio_count_down_500ms > 0)
if (g_fm_radio_mode && g_fm_radio_tick_500ms > 0)
return;
#endif
@ -1833,9 +1830,9 @@ void APP_time_slice_10ms(void)
}
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_fm_restore_count_down_10ms > 0)
if (g_fm_radio_mode && g_fm_restore_tick_10ms > 0)
{
if (--g_fm_restore_count_down_10ms == 0)
if (--g_fm_restore_tick_10ms == 0)
{ // switch back to FM radio mode
FM_Start();
GUI_SelectNextDisplay(DISPLAY_FM);
@ -1843,7 +1840,7 @@ void APP_time_slice_10ms(void)
}
#endif
if (g_screen_to_display == DISPLAY_SEARCH)
if (g_current_display_screen == DISPLAY_SEARCH)
{
uint32_t Result;
int32_t Delta;
@ -2102,7 +2099,7 @@ void APP_time_slice_500ms(void)
// Skipped authentic device check
if (g_serial_config_count_down_500ms > 0)
if (g_serial_config_tick_500ms > 0)
{ // config upload/download is running
return;
}
@ -2152,7 +2149,7 @@ void APP_time_slice_500ms(void)
if (g_menu_count_down > 0)
if (--g_menu_count_down == 0)
exit_menu = (g_screen_to_display == DISPLAY_MENU); // exit menu mode
exit_menu = (g_current_display_screen == DISPLAY_MENU); // exit menu mode
if (g_dtmf_rx_timeout > 0)
if (--g_dtmf_rx_timeout == 0)
@ -2161,9 +2158,9 @@ void APP_time_slice_500ms(void)
// Skipped authentic device check
#ifdef ENABLE_FMRADIO
if (g_fm_radio_count_down_500ms > 0)
if (g_fm_radio_tick_500ms > 0)
{
g_fm_radio_count_down_500ms--;
g_fm_radio_tick_500ms--;
if (g_fm_radio_mode) // 1of11
return;
}
@ -2172,9 +2169,9 @@ void APP_time_slice_500ms(void)
if (g_backlight_count_down > 0 &&
!g_ask_to_save &&
g_css_scan_mode == CSS_SCAN_MODE_OFF &&
g_screen_to_display != DISPLAY_AIRCOPY)
g_current_display_screen != DISPLAY_AIRCOPY)
{
if (g_screen_to_display != DISPLAY_MENU || g_menu_cursor != MENU_AUTO_BACKLITE) // don't turn off backlight if user is in backlight menu option
if (g_current_display_screen != DISPLAY_MENU || g_menu_cursor != MENU_AUTO_BACKLITE) // don't turn off backlight if user is in backlight menu option
if (--g_backlight_count_down == 0)
if (g_eeprom.backlight < (ARRAY_SIZE(g_sub_menu_backlight) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
@ -2224,12 +2221,12 @@ void APP_time_slice_500ms(void)
#endif
{
#ifdef ENABLE_AIRCOPY
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
#endif
{
if (g_css_scan_mode == CSS_SCAN_MODE_OFF &&
g_scan_state_dir == SCAN_STATE_DIR_OFF &&
(g_screen_to_display != DISPLAY_SEARCH ||
(g_current_display_screen != DISPLAY_SEARCH ||
g_search_css_state == SEARCH_CSS_STATE_FOUND ||
g_search_css_state == SEARCH_CSS_STATE_FAILED ||
g_search_css_state == SEARCH_CSS_STATE_REPEAT))
@ -2237,12 +2234,12 @@ void APP_time_slice_500ms(void)
#ifdef ENABLE_KEYLOCK
if (g_eeprom.auto_keypad_lock &&
g_key_lock_count_down_500ms > 0 &&
g_key_lock_tick_500ms > 0 &&
!g_dtmf_input_mode &&
g_input_box_index == 0 &&
g_screen_to_display != DISPLAY_MENU)
g_current_display_screen != DISPLAY_MENU)
{
if (--g_key_lock_count_down_500ms == 0)
if (--g_key_lock_tick_500ms == 0)
{ // lock the keyboard
g_eeprom.key_lock = true;
g_update_status = true;
@ -2263,7 +2260,7 @@ void APP_time_slice_500ms(void)
if (g_input_box_index > 0 || g_dtmf_input_mode)
AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);
/*
if (g_screen_to_display == DISPLAY_SEARCH)
if (g_current_display_screen == DISPLAY_SEARCH)
{
BK4819_StopScan();
@ -2300,7 +2297,7 @@ void APP_time_slice_500ms(void)
if (disp == DISPLAY_INVALID)
{
#ifndef ENABLE_CODE_SEARCH_TIMEOUT
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
#endif
disp = DISPLAY_MAIN;
}
@ -2317,9 +2314,9 @@ void APP_time_slice_500ms(void)
APP_update_rssi(g_eeprom.rx_vfo);
#ifdef ENABLE_FMRADIO
if (!g_ptt_is_pressed && g_fm_resume_count_down_500ms > 0)
if (!g_ptt_is_pressed && g_fm_resume_tick_500ms > 0)
{
if (--g_fm_resume_count_down_500ms == 0)
if (--g_fm_resume_tick_500ms == 0)
{
RADIO_Setg_vfo_state(VFO_STATE_NORMAL);
@ -2388,9 +2385,9 @@ void APP_time_slice_500ms(void)
if (g_current_function != FUNCTION_TRANSMIT)
{
if (g_dtmf_decode_ring_count_down_500ms > 0)
if (g_dtmf_decode_ring_tick_500ms > 0)
{ // make "ring-ring" sound
g_dtmf_decode_ring_count_down_500ms--;
g_dtmf_decode_ring_tick_500ms--;
#ifdef ENABLE_DTMF_CALL_FLASH_LIGHT
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); // light on
@ -2404,7 +2401,7 @@ void APP_time_slice_500ms(void)
}
}
else
g_dtmf_decode_ring_count_down_500ms = 0;
g_dtmf_decode_ring_tick_500ms = 0;
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE &&
g_current_function != FUNCTION_TRANSMIT &&
@ -2429,9 +2426,9 @@ void APP_time_slice_500ms(void)
// }
}
if (g_dtmf_is_tx && g_dtmf_tx_stop_count_down_500ms > 0)
if (g_dtmf_is_tx && g_dtmf_tx_stop_tick_500ms > 0)
{
if (--g_dtmf_tx_stop_count_down_500ms == 0)
if (--g_dtmf_tx_stop_tick_500ms == 0)
{
g_dtmf_is_tx = false;
g_update_display = true;
@ -2439,7 +2436,7 @@ void APP_time_slice_500ms(void)
}
#ifdef ENABLE_TX_TIMEOUT_BAR
if (g_current_function == FUNCTION_TRANSMIT && (g_tx_timer_count_down_500ms & 1))
if (g_current_function == FUNCTION_TRANSMIT && (g_tx_timer_tick_500ms & 1))
UI_DisplayTXCountdown(true);
#endif
}
@ -2466,7 +2463,7 @@ void APP_time_slice_500ms(void)
RADIO_setup_registers(true);
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
if (g_current_display_screen != DISPLAY_MENU) // 1of11 .. don't close the menu
g_request_display_screen = DISPLAY_MAIN;
}
#endif
@ -2546,12 +2543,12 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
FUNCTION_Select(FUNCTION_FOREGROUND);
// stay awake - for now
g_battery_save_count_down_10ms = battery_save_count_10ms;
g_battery_save_tick_10ms = battery_save_count_10ms;
#ifdef ENABLE_KEYLOCK
// keep the auto keylock at bay
if (g_eeprom.auto_keypad_lock)
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
g_key_lock_tick_500ms = key_lock_timeout_500ms;
#endif
if (g_fkey_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
@ -2628,12 +2625,12 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
APP_cancel_user_input_modes();
}
if (key_pressed && g_screen_to_display == DISPLAY_MENU)
if (key_pressed && g_current_display_screen == DISPLAY_MENU)
g_menu_count_down = menu_timeout_500ms;
// cancel the ringing
if (key_pressed && g_dtmf_decode_ring_count_down_500ms > 0)
g_dtmf_decode_ring_count_down_500ms = 0;
if (key_pressed && g_dtmf_decode_ring_tick_500ms > 0)
g_dtmf_decode_ring_tick_500ms = 0;
// ********************
@ -2783,7 +2780,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
else
if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
{
switch (g_screen_to_display)
switch (g_current_display_screen)
{
case DISPLAY_MAIN:
MAIN_process_key(Key, key_pressed, key_held);
@ -2816,9 +2813,9 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
}
else
#ifdef ENABLE_AIRCOPY
if (g_screen_to_display != DISPLAY_SEARCH && g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_SEARCH && g_current_display_screen != DISPLAY_AIRCOPY)
#else
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
#endif
{
ACTION_process(Key, key_pressed, key_held);
@ -2895,7 +2892,7 @@ Skip:
{
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, g_request_save_channel);
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
if (g_vfo_configure_mode == VFO_CONFIGURE_NONE) // don't wipe previous variable setting
g_vfo_configure_mode = VFO_CONFIGURE;
}
@ -2944,7 +2941,7 @@ Skip:
g_dtmf_auto_reset_time_500ms = 0;
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_dtmf_tx_stop_count_down_500ms = 0;
g_dtmf_tx_stop_tick_500ms = 0;
g_dtmf_is_tx = false;
g_vfo_rssi_bar_level[0] = 0;

View File

@ -53,14 +53,14 @@ char g_dtmf_id[4];
char g_dtmf_caller[4];
char g_dtmf_callee[4];
dtmf_state_t g_dtmf_state;
uint8_t g_dtmf_decode_ring_count_down_500ms;
uint8_t g_dtmf_decode_ring_tick_500ms;
uint8_t g_dtmf_chosen_contact;
uint8_t g_dtmf_auto_reset_time_500ms;
dtmf_call_state_t g_dtmf_call_state;
dtmf_reply_state_t g_dtmf_reply_state;
dtmf_call_mode_t g_dtmf_call_mode;
bool g_dtmf_is_tx;
uint8_t g_dtmf_tx_stop_count_down_500ms;
uint8_t g_dtmf_tx_stop_tick_500ms;
bool g_dtmf_IsGroupCall;
void DTMF_clear_RX(void)
@ -367,16 +367,16 @@ void DTMF_HandleRequest(void)
switch (g_eeprom.dtmf_decode_response)
{
case DTMF_DEC_RESPONSE_BOTH:
g_dtmf_decode_ring_count_down_500ms = dtmf_decode_ring_countdown_500ms;
g_dtmf_decode_ring_tick_500ms = dtmf_decode_ring_500ms;
case DTMF_DEC_RESPONSE_REPLY:
g_dtmf_reply_state = DTMF_REPLY_AAAAA;
break;
case DTMF_DEC_RESPONSE_RING:
g_dtmf_decode_ring_count_down_500ms = dtmf_decode_ring_countdown_500ms;
g_dtmf_decode_ring_tick_500ms = dtmf_decode_ring_500ms;
break;
default:
case DTMF_DEC_RESPONSE_NONE:
g_dtmf_decode_ring_count_down_500ms = 0;
g_dtmf_decode_ring_tick_500ms = 0;
g_dtmf_reply_state = DTMF_REPLY_NONE;
break;
}

View File

@ -85,14 +85,14 @@ extern char g_dtmf_id[4];
extern char g_dtmf_caller[4];
extern char g_dtmf_callee[4];
extern dtmf_state_t g_dtmf_state;
extern uint8_t g_dtmf_decode_ring_count_down_500ms;
extern uint8_t g_dtmf_decode_ring_tick_500ms;
extern uint8_t g_dtmf_chosen_contact;
extern uint8_t g_dtmf_auto_reset_time_500ms;
extern dtmf_call_state_t g_dtmf_call_state;
extern dtmf_reply_state_t g_dtmf_reply_state;
extern dtmf_call_mode_t g_dtmf_call_mode;
extern bool g_dtmf_is_tx;
extern uint8_t g_dtmf_tx_stop_count_down_500ms;
extern uint8_t g_dtmf_tx_stop_tick_500ms;
void DTMF_clear_RX(void);
bool DTMF_ValidateCodes(char *pCode, const unsigned int size);

View File

@ -40,15 +40,15 @@
uint16_t g_fm_channels[20];
bool g_fm_radio_mode;
uint8_t g_fm_radio_count_down_500ms;
volatile uint16_t g_fm_play_count_down_10ms;
uint8_t g_fm_radio_tick_500ms;
volatile uint16_t g_fm_play_tick_10ms;
volatile int8_t g_fm_scan_state;
bool g_fm_auto_scan;
uint8_t g_fm_channel_position;
bool g_fm_found_frequency;
bool g_fm_auto_scan;
uint8_t g_fm_resume_count_down_500ms;
uint16_t g_fm_restore_count_down_10ms;
uint8_t g_fm_resume_tick_500ms;
uint16_t g_fm_restore_tick_10ms;
bool FM_CheckValidChannel(uint8_t Channel)
{
@ -100,7 +100,7 @@ void FM_TurnOff(void)
{
g_fm_radio_mode = false;
g_fm_scan_state = FM_SCAN_OFF;
g_fm_restore_count_down_10ms = 0;
g_fm_restore_tick_10ms = 0;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
@ -129,7 +129,7 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool flag)
g_speaker_enabled = false;
g_fm_play_count_down_10ms = (g_fm_scan_state == FM_SCAN_OFF) ? fm_play_countdown_noscan_10ms : fm_play_countdown_scan_10ms;
g_fm_play_tick_10ms = (g_fm_scan_state == FM_SCAN_OFF) ? fm_play_noscan_10ms : fm_play_scan_10ms;
g_schedule_fm = false;
g_fm_found_frequency = false;
@ -168,7 +168,7 @@ void FM_PlayAndUpdate(void)
BK1080_SetFrequency(g_eeprom.fm_frequency_playing);
SETTINGS_save_fm();
g_fm_play_count_down_10ms = 0;
g_fm_play_tick_10ms = 0;
g_schedule_fm = false;
g_ask_to_save = false;
@ -386,14 +386,18 @@ static void FM_Key_STAR(bool key_pressed, bool key_held)
{
g_key_input_count_down = key_input_timeout_500ms;
if (key_held && !key_pressed)
return;
if (!key_held && !key_pressed)
ACTION_Scan(false); // short key press just released .. scan without store
{
ACTION_Scan(false); // short key press just released .. frequency scan without store
}
else
if (key_held && key_pressed)
ACTION_Scan(true); // long key press still pressed .. scan and store
{
ACTION_Scan(true); // long key press still pressed .. frequency scan and store
}
g_fkey_pressed = false;
g_update_status = true;
}
static void FM_Key_EXIT(bool key_pressed, bool key_held)
@ -656,7 +660,7 @@ void FM_Play(void)
{
if (!g_fm_auto_scan)
{
g_fm_play_count_down_10ms = 0;
g_fm_play_tick_10ms = 0;
g_fm_found_frequency = true;
if (!g_eeprom.fm_channel_mode)
@ -692,7 +696,7 @@ void FM_Start(void)
{
g_fm_radio_mode = true;
g_fm_scan_state = FM_SCAN_OFF;
g_fm_restore_count_down_10ms = 0;
g_fm_restore_tick_10ms = 0;
BK1080_Init(g_eeprom.fm_frequency_playing, true);

View File

@ -28,8 +28,8 @@ enum {
extern uint16_t g_fm_channels[20];
extern bool g_fm_radio_mode;
extern uint8_t g_fm_radio_count_down_500ms;
extern volatile uint16_t g_fm_play_count_down_10ms;
extern uint8_t g_fm_radio_tick_500ms;
extern volatile uint16_t g_fm_play_tick_10ms;
extern volatile int8_t g_fm_scan_state;
extern bool g_fm_auto_scan;
extern uint8_t g_fm_channel_position;
@ -37,8 +37,8 @@ extern uint8_t g_fm_channel_position;
extern uint16_t g_fm_frequency_deviation;
extern bool g_fm_found_frequency;
extern bool g_fm_auto_scan;
extern uint8_t g_fm_resume_count_down_500ms;
extern uint16_t g_fm_restore_count_down_10ms;
extern uint8_t g_fm_resume_tick_500ms;
extern uint16_t g_fm_restore_tick_10ms;
bool FM_CheckValidChannel(uint8_t Channel);
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction);

View File

@ -54,7 +54,7 @@ void GENERIC_Key_F(bool key_pressed, bool key_held)
{ // f-key held
#ifdef ENABLE_KEYLOCK
if (key_pressed && g_screen_to_display != DISPLAY_MENU && g_current_function != FUNCTION_TRANSMIT)
if (key_pressed && g_current_display_screen != DISPLAY_MENU && g_current_function != FUNCTION_TRANSMIT)
{ // toggle the keyboad lock
#ifdef ENABLE_VOICE
@ -101,7 +101,7 @@ void GENERIC_Key_PTT(bool key_pressed)
{
g_input_box_index = 0;
if (!key_pressed || g_serial_config_count_down_500ms > 0)
if (!key_pressed || g_serial_config_tick_500ms > 0)
{ // PTT released
if (g_current_function == FUNCTION_TRANSMIT)
@ -129,7 +129,7 @@ void GENERIC_Key_PTT(bool key_pressed)
RADIO_Setg_vfo_state(VFO_STATE_NORMAL);
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
if (g_current_display_screen != DISPLAY_MENU) // 1of11 .. don't close the menu
g_request_display_screen = DISPLAY_MAIN;
}
@ -143,11 +143,11 @@ void GENERIC_Key_PTT(bool key_pressed)
#endif
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || // freq/chan scanning
g_screen_to_display == DISPLAY_SEARCH || // CTCSS/CDCSS scanning
g_current_display_screen == DISPLAY_SEARCH || // CTCSS/CDCSS scanning
g_css_scan_mode != CSS_SCAN_MODE_OFF) // " "
{ // we're scanning .. stop
if (g_screen_to_display == DISPLAY_SEARCH)
if (g_current_display_screen == DISPLAY_SEARCH)
{ // CTCSS/CDCSS scanning .. stop
g_eeprom.cross_vfo_rx_tx = g_backup_cross_vfo_rx_tx;
g_search_flag_stop_scan = true;
@ -184,7 +184,7 @@ void GENERIC_Key_PTT(bool key_pressed)
goto cancel_tx;
}
if (g_screen_to_display == DISPLAY_FM)
if (g_current_display_screen == DISPLAY_FM)
goto start_tx; // listening to the FM radio .. start TX'ing
#endif
@ -194,7 +194,7 @@ void GENERIC_Key_PTT(bool key_pressed)
return;
}
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
if (g_current_display_screen != DISPLAY_MENU) // 1of11 .. don't close the menu
g_request_display_screen = DISPLAY_MAIN;
if (!g_dtmf_input_mode && g_dtmf_input_box_index == 0)
@ -247,7 +247,7 @@ cancel_tx:
done:
g_ptt_debounce = 0;
if (g_screen_to_display != DISPLAY_MENU && g_request_display_screen != DISPLAY_FM) // 1of11 .. don't close the menu
if (g_current_display_screen != DISPLAY_MENU && g_request_display_screen != DISPLAY_FM) // 1of11 .. don't close the menu
g_request_display_screen = DISPLAY_MAIN;
g_update_status = true;
g_update_display = true;

View File

@ -65,7 +65,7 @@ void toggle_chan_scanlist(void)
return;
}
if (g_screen_to_display != DISPLAY_MAIN ||
if (g_current_display_screen != DISPLAY_MAIN ||
g_current_function == FUNCTION_TRANSMIT ||
g_current_function == FUNCTION_PANADAPTER)
{
@ -157,7 +157,7 @@ void toggle_chan_scanlist(void)
break;
}
g_screen_to_display = DISPLAY_INVALID;
g_current_display_screen = DISPLAY_INVALID;
GUI_SelectNextDisplay(DISPLAY_MENU);
g_menu_cursor = MENU_MEM_SAVE;
g_in_sub_menu = true;
@ -169,7 +169,7 @@ void toggle_chan_scanlist(void)
g_sub_menu_selection = chan;
g_flag_refresh_menu = false;
g_screen_to_display = DISPLAY_MENU;
g_current_display_screen = DISPLAY_MENU;
g_update_display = false;
UI_DisplayMenu();
}
@ -188,7 +188,7 @@ void processFKeyFunction(const key_code_t Key)
uint8_t Band;
uint8_t Vfo = g_eeprom.tx_vfo;
if (g_current_function == FUNCTION_TRANSMIT || g_screen_to_display == DISPLAY_MENU)
if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen == DISPLAY_MENU)
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
@ -424,7 +424,7 @@ void MAIN_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
if (key_pressed)
{ // and pressed
if (g_screen_to_display == DISPLAY_MAIN)
if (g_current_display_screen == DISPLAY_MAIN)
{
if (g_input_box_index > 0)
{ // clear the user box
@ -697,7 +697,7 @@ void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
g_fkey_pressed = false;
if (g_screen_to_display == DISPLAY_MAIN)
if (g_current_display_screen == DISPLAY_MAIN)
{
if (g_input_box_index > 0)
{ // delete any inputted chars

View File

@ -630,7 +630,7 @@ void MENU_AcceptSetting(void)
#ifdef ENABLE_KEYLOCK
case MENU_AUTO_KEY_LOCK:
g_eeprom.auto_keypad_lock = g_sub_menu_selection;
g_key_lock_count_down_500ms = key_lock_timeout_500ms;
g_key_lock_tick_500ms = key_lock_timeout_500ms;
break;
#endif
@ -2013,7 +2013,7 @@ void MENU_process_key(key_code_t Key, bool key_pressed, bool key_held)
break;
}
if (g_screen_to_display == DISPLAY_MENU)
if (g_current_display_screen == DISPLAY_MENU)
{
if (g_menu_cursor == MENU_VOLTAGE ||
#ifdef ENABLE_F_CAL_MENU

View File

@ -247,7 +247,7 @@ static void cmd_0514(const uint8_t *pBuffer)
time_stamp = pCmd->time_stamp;
g_serial_config_count_down_500ms = serial_config_count_down_500ms;
g_serial_config_tick_500ms = serial_config_tick_500ms;
// show message
g_request_display_screen = DISPLAY_MAIN;
@ -268,7 +268,7 @@ static void cmd_051B(const uint8_t *pBuffer)
// if (pCmd->time_stamp != time_stamp)
// return;
g_serial_config_count_down_500ms = serial_config_count_down_500ms;
g_serial_config_tick_500ms = serial_config_tick_500ms;
if (addr >= EEPROM_SIZE)
return;
@ -312,7 +312,7 @@ static void cmd_051D(const uint8_t *pBuffer)
// if (pCmd->time_stamp != time_stamp)
// return;
g_serial_config_count_down_500ms = serial_config_count_down_500ms;
g_serial_config_tick_500ms = serial_config_tick_500ms;
if (addr >= EEPROM_SIZE)
return;
@ -418,7 +418,7 @@ static void cmd_052D(const uint8_t *pBuffer)
uint32_t response[4];
reply_052D_t reply;
g_serial_config_count_down_500ms = serial_config_count_down_500ms;
g_serial_config_tick_500ms = serial_config_tick_500ms;
if (!locked)
{
@ -472,7 +472,7 @@ static void cmd_052F(const uint8_t *pBuffer)
g_eeprom.vfo_info[0].dtmf_ptt_id_tx_mode = PTT_ID_OFF;
g_eeprom.vfo_info[0].dtmf_decoding_enable = false;
g_serial_config_count_down_500ms = serial_config_count_down_500ms;
g_serial_config_tick_500ms = serial_config_tick_500ms;
#ifdef ENABLE_NOAA
g_is_noaa_mode = false;

View File

@ -68,7 +68,7 @@
voice_id_t g_voice_id[8];
uint8_t g_voice_read_index;
uint8_t g_voice_write_index;
volatile uint16_t g_count_down_to_play_next_voice_10ms;
volatile uint16_t g_tick_to_play_next_voice_10ms;
volatile bool g_flag_play_queued_voice;
voice_id_t g_another_voice_id = VOICE_ID_INVALID;
@ -95,7 +95,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
}
#ifdef ENABLE_AIRCOPY
// if (g_screen_to_display == DISPLAY_AIRCOPY || g_aircopy_state != AIRCOPY_READY)
// if (g_current_display_screen == DISPLAY_AIRCOPY || g_aircopy_state != AIRCOPY_READY)
// return;
#endif
if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR)
@ -338,7 +338,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
}
g_voice_read_index = 1;
g_count_down_to_play_next_voice_10ms = Delay;
g_tick_to_play_next_voice_10ms = Delay;
g_flag_play_queued_voice = false;
return;
@ -450,7 +450,7 @@ void AUDIO_PlayBeep(beep_type_t Beep)
AUDIO_PlayVoice(VoiceID);
g_count_down_to_play_next_voice_10ms = Delay;
g_tick_to_play_next_voice_10ms = Delay;
g_flag_play_queued_voice = false;
#ifdef ENABLE_VOX

View File

@ -129,7 +129,7 @@ typedef enum voice_id_e voice_id_t;
extern voice_id_t g_voice_id[8];
extern uint8_t g_voice_read_index;
extern uint8_t g_voice_write_index;
extern volatile uint16_t g_count_down_to_play_next_voice_10ms;
extern volatile uint16_t g_tick_to_play_next_voice_10ms;
extern volatile bool g_flag_play_queued_voice;
extern voice_id_t g_another_voice_id;

View File

@ -21,17 +21,60 @@
#include "driver/system.h"
#include "misc.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#if defined(ENABLE_FMRADIO_64_76)
#define BAND 3u
#elif defined(ENABLE_FMRADIO_76_90)
#define BAND 2u
#elif defined(ENABLE_FMRADIO_76_108)
#define BAND 1u
#elif defined(ENABLE_FMRADIO_875_108)
#define BAND 0u
#endif
//#define CHAN_SPACING 0u // 200kHz
#define CHAN_SPACING 1u // 100kHz
//#define CHAN_SPACING 2u // 50kHz
#define VOLUME 15u
#define SEEK_THRESHOLD 10u
static const uint16_t BK1080_RegisterTable[] =
{
0x0008, 0x1080, 0x0201, 0x0000, 0x40C0, 0x0A1F, 0x002E, 0x02FF,
0x5B11, 0x0000, 0x411E, 0x0000, 0xCE00, 0x0000, 0x0000, 0x1000,
0x3197, 0x0000, 0x13FF, 0x9852, 0x0000, 0x0000, 0x0008, 0x0000,
0x51E1, 0xA8BC, 0x2645, 0x00E4, 0x1CD8, 0x3A50, 0xEAE0, 0x3000,
0x0200, 0x0000,
0x0008, // 0x00
0x1080, // 0x01 chip ID
(1u << 9) | (1u << 0), // 0x02 0x0201 0000001000000001
0x0000, // 0x03
0x40C0, // 0x04 0100000011000000
(SEEK_THRESHOLD << 8) | (BAND << 6) | (CHAN_SPACING << 4) | (VOLUME << 0), // 0x0A1F, // 0x05 00001010 00 01 1111
0x002E, // 0x06 0000000000101110
0x02FF, // 0x07 0000001011111111
0x5B11, // 0x08 0101101100010001
0x0000, // 0x09
0x411E, // 0x0A 0100000100011110
0x0000, // 0x0B
0xCE00, // 0x0C 1100111000000000
0x0000, // 0x0D
0x0000, // 0x0E
0x1000, // 0x0F 1000000000000000
0x3197, // 0x10 0011000110010111
0x0000, // 0x11
0x13FF, // 0x12 0001001111111111
0x9852, // 0x13 1001100001010010
0x0000, // 0x14
0x0000, // 0x15
0x0008, // 0x16
0x0000, // 0x17
0x51E1, // 0x18 0101000111100001
0xA8BC, // 0x19 1010100010111100
0x2645, // 0x1A 0010011001000101
0x00E4, // 0x1B 0000000011100100
0x1CD8, // 0x1C 0001110011011000
0x3A50, // 0x1D 0011101001010000
0xEAE0, // 0x1E 1110101011100000
0x3000, // 0x1F 0011000000000000
0x0200, // 0x20 0010000000000000
0x0000 // 0x21
};
bool is_init;
@ -62,17 +105,17 @@ void BK1080_Init(uint16_t Frequency, bool bDoScan)
}
else
{
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, (1u << 9) | (1u << 0));
}
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
// SYSTEM_DelayMs(10);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | (1u << 15));
// BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F);
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, (SEEK_THRESHOLD << 8) | (BAND << 6) | (CHAN_SPACING << 4) | (VOLUME << 0));
BK1080_SetFrequency(Frequency);
}
else
{
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241);
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, (1u << 9) | (1u << 6) | (1u << 0)); // 0x0241); // 0000 0010 0100 0001
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
}
}
@ -101,18 +144,42 @@ void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value)
void BK1080_Mute(bool Mute)
{
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201);
uint16_t val = (1u << 9) | (1u << 0);
if (Mute)
val |= 1u << 14;
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, val);
}
void BK1080_SetFrequency(uint16_t Frequency)
{
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
#if defined(ENABLE_FMRADIO_64_76)
const uint16_t channel = Frequency - 640; // 100kHz channel spacing
#elif defined(ENABLE_FMRADIO_76_90)
const uint16_t channel = Frequency - 760; // 100kHz channel spacing
#elif defined(ENABLE_FMRADIO_76_108)
const uint16_t channel = Frequency - 760; // 100kHz channel spacing
#elif defined(ENABLE_FMRADIO_875_108)
// const uint16_t channel = Frequency - 760;
const uint16_t channel = Frequency - 875; // 100kHz channel spacing
#endif
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel);
// SYSTEM_DelayMs(10);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | (1u << 15));
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, channel | (1u << 15));
}
void BK1080_GetFrequencyDeviation(uint16_t Frequency)
uint16_t BK1080_GetFrequencyDeviation(uint16_t Frequency)
{
BK1080_BaseFrequency = Frequency;
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16;
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) >> 4;
return BK1080_FrequencyDeviation;
}

View File

@ -30,7 +30,7 @@ uint16_t BK1080_ReadRegister(BK1080_Register_t Register);
void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value);
void BK1080_Mute(bool Mute);
void BK1080_SetFrequency(uint16_t Frequency);
void BK1080_GetFrequencyDeviation(uint16_t Frequency);
uint16_t BK1080_GetFrequencyDeviation(uint16_t Frequency);
#endif

View File

@ -59,10 +59,11 @@ void BK4819_Init(void)
BK4819_EnableAGC(); // only do this in linear modulation modes, not FM
#endif
// BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable
// BK4819_WriteRegister(0x7D, 0xE940); // 111010010100 0000
BK4819_WriteRegister(0x7D, 0xE940 | 0x1f);
BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable
BK4819_WriteRegister(0x7D, 0xE940);
// REG_48 .. RX AF level
//
// <15:12> 11 ??? 0 to 15

Binary file not shown.

Binary file not shown.

View File

@ -27,10 +27,10 @@ uint32_t g_aircopy_freq = 41002500;
const freq_band_table_t AIR_BAND = {10800000, 13700000};
// FM broadcast band lower/upper limit
#if defined(ENABLE_FMRADIO_76_90)
#if defined(ENABLE_FMRADIO_64_76)
const freq_band_table_t FM_RADIO_BAND = {640, 760};
#elif defined(ENABLE_FMRADIO_76_90)
const freq_band_table_t FM_RADIO_BAND = {760, 900};
#elif defined(ENABLE_FMRADIO_68_108)
const freq_band_table_t FM_RADIO_BAND = {680, 1080};
#elif defined(ENABLE_FMRADIO_76_108)
const freq_band_table_t FM_RADIO_BAND = {760, 1080};
#elif defined(ENABLE_FMRADIO_875_108)

View File

@ -70,15 +70,15 @@ void FUNCTION_Init(void)
g_squelch_open = false;
g_flag_tail_tone_elimination_complete = false;
g_tail_tone_elimination_count_down_10ms = 0;
g_tail_tone_elimination_tick_10ms = 0;
g_found_ctcss = false;
g_found_cdcss = false;
g_found_ctcss_count_down_10ms = 0;
g_found_cdcss_count_down_10ms = 0;
g_found_ctcss_tick_10ms = 0;
g_found_cdcss_tick_10ms = 0;
g_end_of_rx_detected_maybe = false;
#ifdef ENABLE_NOAA
g_noaa_count_down_10ms = 0;
g_noaa_tick_10ms = 0;
#endif
g_update_status = true;
@ -123,7 +123,7 @@ void FUNCTION_Select(function_type_t Function)
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
g_fm_restore_count_down_10ms = fm_restore_countdown_10ms;
g_fm_restore_tick_10ms = fm_restore_10ms;
#endif
if (g_dtmf_call_state == DTMF_CALL_STATE_CALL_OUT ||
@ -174,7 +174,7 @@ void FUNCTION_Select(function_type_t Function)
BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false);
if (g_screen_to_display != DISPLAY_MENU) // 1of11 .. don't close the menu
if (g_current_display_screen != DISPLAY_MENU) // 1of11 .. don't close the menu
GUI_SelectNextDisplay(DISPLAY_MAIN);
return;
@ -303,11 +303,11 @@ void FUNCTION_Select(function_type_t Function)
break;
}
g_battery_save_count_down_10ms = battery_save_count_10ms;
g_battery_save_tick_10ms = battery_save_count_10ms;
g_schedule_power_save = false;
#ifdef ENABLE_FMRADIO
g_fm_restore_count_down_10ms = 0;
g_fm_restore_tick_10ms = 0;
#endif
g_update_status = true;

View File

@ -106,7 +106,7 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel)
g_battery_voltage_average = (Voltage * 760) / g_battery_calibration[3];
if ((g_screen_to_display == DISPLAY_MENU) && g_menu_cursor == MENU_VOLTAGE)
if ((g_current_display_screen == DISPLAY_MENU) && g_menu_cursor == MENU_VOLTAGE)
g_update_display = true;
if (g_usb_current < 501)

6
main.c
View File

@ -27,6 +27,9 @@
#include "bsp/dp32g030/syscon.h"
#include "board.h"
#include "driver/backlight.h"
#ifdef ENABLE_FMRADIO
#include "driver/bk1080.h"
#endif
#include "driver/bk4819.h"
#include "driver/gpio.h"
#include "driver/st7565.h"
@ -94,6 +97,9 @@ void Main(void)
#if defined(ENABLE_UART)
UART_printf("BK4819 id %04X rev %04X\r\n", BK4819_ReadRegister(0x00), BK4819_ReadRegister(0x01));
#ifdef ENABLE_FMRADIO
UART_printf("BK1080 id %04X rev %04X\r\n", BK1080_ReadRegister(0x01), BK1080_ReadRegister(0x00));
#endif
#endif
#ifdef ENABLE_MDC1200

44
misc.c
View File

@ -25,11 +25,11 @@ const uint8_t obfuscate_array[16] = {
// ***********************************************
const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 seconds
const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds
const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms
const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds
const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds
const uint8_t fm_resume_500ms = 2500 / 500; // 2.5 seconds
const uint8_t fm_radio_500ms = 2000 / 500; // 2 seconds
const uint16_t fm_play_scan_10ms = 40 / 10; // 40ms
const uint16_t fm_play_noscan_10ms = 1200 / 10; // 1.2 seconds
const uint16_t fm_restore_10ms = 5000 / 10; // 5 seconds
const uint8_t menu_timeout_500ms = 30000 / 500; // 30 seconds
const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 minutes
@ -38,10 +38,10 @@ const uint16_t backlight_tx_rx_time_500ms = 10000 / 500; // 10 se
const uint8_t dtmf_rx_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen
const uint8_t dtmf_rx_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver
const uint8_t dtmf_decode_ring_countdown_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for
const uint8_t dtmf_txstop_countdown_500ms = 3000 / 500; // 6 seconds
const uint8_t dtmf_decode_ring_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for
const uint8_t dtmf_txstop_500ms = 3000 / 500; // 6 seconds
const uint8_t serial_config_count_down_500ms = 3000 / 500; // 3 seconds
const uint8_t serial_config_tick_500ms = 3000 / 500; // 3 seconds
const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds
#ifdef ENABLE_KEYLOCK
@ -75,12 +75,12 @@ const uint16_t power_save1_10ms = 100 / 10; // 100ms
const uint16_t power_save2_10ms = 200 / 10; // 200ms
#ifdef ENABLE_VOX
const uint16_t vox_stop_count_down_10ms = 1000 / 10; // 1 second
const uint16_t vox_stop_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_tick_10ms = 5000 / 10; // 5 seconds
const uint16_t noaa_tick_2_10ms = 500 / 10; // 500ms
const uint16_t noaa_tick_3_10ms = 200 / 10; // 200ms
// ***********************************************
@ -139,7 +139,7 @@ uint16_t g_eeprom_rssi_calib[7][4];
uint8_t g_user_channel_attributes[FREQ_CHANNEL_LAST + 1];
volatile uint16_t g_battery_save_count_down_10ms = battery_save_count_10ms;
volatile uint16_t g_battery_save_tick_10ms = battery_save_count_10ms;
volatile bool g_power_save_expired;
volatile bool g_schedule_power_save;
@ -147,23 +147,23 @@ volatile bool g_schedule_power_save;
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;
volatile uint8_t g_serial_config_tick_500ms;
volatile bool g_next_time_slice_500ms;
volatile uint16_t g_tx_timer_count_down_500ms;
volatile uint16_t g_tx_timer_tick_500ms;
volatile bool g_tx_timeout_reached;
volatile uint16_t g_tail_tone_elimination_count_down_10ms;
volatile uint16_t g_tail_tone_elimination_tick_10ms;
#ifdef ENABLE_NOAA
volatile uint16_t g_noaa_count_down_10ms;
volatile uint16_t g_noaa_tick_10ms;
#endif
bool g_speaker_enabled;
uint8_t g_key_input_count_down;
#ifdef ENABLE_KEYLOCK
uint8_t g_key_lock_count_down_500ms;
uint8_t g_key_lock_tick_500ms;
#endif
uint8_t g_rtte_count_down;
bool g_password_locked;
@ -249,14 +249,14 @@ bool g_update_display;
bool g_unhide_hidden = false;
volatile bool g_next_time_slice;
volatile uint8_t g_found_cdcss_count_down_10ms;
volatile uint8_t g_found_ctcss_count_down_10ms;
volatile uint8_t g_found_cdcss_tick_10ms;
volatile uint8_t g_found_ctcss_tick_10ms;
#ifdef ENABLE_VOX
volatile uint16_t g_vox_stop_count_down_10ms;
volatile uint16_t g_vox_stop_10ms;
#endif
volatile bool g_next_time_slice_40ms;
#ifdef ENABLE_NOAA
volatile uint16_t g_noaa_count_down_10ms = 0;
volatile uint16_t g_noaa_tick_10ms = 0;
volatile bool g_schedule_noaa = true;
#endif
volatile bool g_flag_tail_tone_elimination_complete;

46
misc.h
View File

@ -110,11 +110,11 @@ typedef enum scan_state_dir_e scan_state_dir_t;
extern const uint8_t obfuscate_array[16];
extern const uint8_t fm_resume_countdown_500ms;
extern const uint8_t fm_radio_countdown_500ms;
extern const uint16_t fm_play_countdown_scan_10ms;
extern const uint16_t fm_play_countdown_noscan_10ms;
extern const uint16_t fm_restore_countdown_10ms;
extern const uint8_t fm_resume_500ms;
extern const uint8_t fm_radio_500ms;
extern const uint16_t fm_play_scan_10ms;
extern const uint16_t fm_play_noscan_10ms;
extern const uint16_t fm_restore_10ms;
extern const uint8_t menu_timeout_500ms;
extern const uint16_t menu_timeout_long_500ms;
@ -123,10 +123,10 @@ extern const uint16_t backlight_tx_rx_time_500ms;
extern const uint8_t dtmf_rx_live_timeout_500ms;
extern const uint8_t dtmf_rx_timeout_500ms;
extern const uint8_t dtmf_decode_ring_countdown_500ms;
extern const uint8_t dtmf_txstop_countdown_500ms;
extern const uint8_t dtmf_decode_ring_500ms;
extern const uint8_t dtmf_txstop_500ms;
extern const uint8_t serial_config_count_down_500ms;
extern const uint8_t serial_config_tick_500ms;
extern const uint8_t key_input_timeout_500ms;
@ -147,12 +147,12 @@ extern const uint16_t power_save1_10ms;
extern const uint16_t power_save2_10ms;
#ifdef ENABLE_VOX
extern const uint16_t vox_stop_count_down_10ms;
extern const uint16_t vox_stop_10ms;
#endif
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 noaa_tick_10ms;
extern const uint16_t noaa_tick_2_10ms;
extern const uint16_t noaa_tick_3_10ms;
#ifdef ENABLE_VOX
extern const uint16_t dual_watch_delay_after_vox_10ms;
@ -223,7 +223,7 @@ extern uint16_t g_eeprom_rssi_calib[7][4];
extern uint8_t g_user_channel_attributes[207];
extern volatile uint16_t g_battery_save_count_down_10ms;
extern volatile uint16_t g_battery_save_tick_10ms;
extern volatile bool g_power_save_expired;
extern volatile bool g_schedule_power_save;
@ -231,26 +231,26 @@ extern volatile bool g_schedule_power_save;
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;
extern volatile uint8_t g_serial_config_tick_500ms;
extern volatile bool g_next_time_slice_500ms;
extern volatile uint16_t g_tx_timer_count_down_500ms;
extern volatile uint16_t g_tx_timer_tick_500ms;
extern volatile bool g_tx_timeout_reached;
extern volatile uint16_t g_tail_tone_elimination_count_down_10ms;
extern volatile uint16_t g_tail_tone_elimination_tick_10ms;
#ifdef ENABLE_FMRADIO
extern volatile uint16_t g_fm_play_count_down_10ms;
extern volatile uint16_t g_fm_play_tick_10ms;
#endif
#ifdef ENABLE_NOAA
extern volatile uint16_t g_noaa_count_down_10ms;
extern volatile uint16_t g_noaa_tick_10ms;
#endif
extern bool g_speaker_enabled;
extern uint8_t g_key_input_count_down;
#ifdef ENABLE_KEYLOCK
extern uint8_t g_key_lock_count_down_500ms;
extern uint8_t g_key_lock_tick_500ms;
#endif
extern uint8_t g_rtte_count_down;
@ -330,14 +330,14 @@ extern bool g_unhide_hidden;
#ifdef ENABLE_FMRADIO
extern uint8_t g_fm_channel_position;
#endif
extern volatile uint8_t g_found_cdcss_count_down_10ms;
extern volatile uint8_t g_found_ctcss_count_down_10ms;
extern volatile uint8_t g_found_cdcss_tick_10ms;
extern volatile uint8_t g_found_ctcss_tick_10ms;
#ifdef ENABLE_VOX
extern volatile uint16_t g_vox_stop_count_down_10ms;
extern volatile uint16_t g_vox_stop_10ms;
#endif
extern volatile bool g_next_time_slice_40ms;
#ifdef ENABLE_NOAA
extern volatile uint16_t g_noaa_count_down_10ms;
extern volatile uint16_t g_noaa_tick_10ms;
extern volatile bool g_schedule_noaa;
#endif
extern volatile bool g_flag_tail_tone_elimination_complete;

21
radio.c
View File

@ -675,6 +675,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
// mic gain 0.5dB/step 0 to 31
BK4819_WriteRegister(0x7D, 0xE940 | (g_eeprom.mic_sensitivity_tuning & 0x1f));
// BK4819_WriteRegister(0x19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_is_noaa_mode)
@ -873,7 +874,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
{
g_is_noaa_mode = true;
g_noaa_channel = g_rx_vfo->channel_save - NOAA_CHANNEL_FIRST;
g_noaa_count_down_10ms = noaa_count_down_2_10ms;
g_noaa_tick_10ms = noaa_tick_2_10ms;
g_schedule_noaa = false;
}
else
@ -925,7 +926,7 @@ void RADIO_enableTX(const bool fsk_tx)
BK4819_PrepareTransmit();
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, true); // PA on
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
BK4819_SetupPowerAmplifier(g_current_vfo->txp_calculated_setting, g_current_vfo->p_tx->frequency);
else
BK4819_SetupPowerAmplifier(0, g_current_vfo->p_tx->frequency); // very low power when in AIRCOPY mode
@ -965,7 +966,7 @@ void RADIO_Setg_vfo_state(vfo_state_t State)
g_vfo_state[1] = VFO_STATE_NORMAL;
#ifdef ENABLE_FMRADIO
g_fm_resume_count_down_500ms = 0;
g_fm_resume_tick_500ms = 0;
#endif
}
else
@ -982,7 +983,7 @@ void RADIO_Setg_vfo_state(vfo_state_t State)
}
#ifdef ENABLE_FMRADIO
g_fm_resume_count_down_500ms = fm_resume_countdown_500ms;
g_fm_resume_tick_500ms = fm_resume_500ms;
#endif
}
@ -1025,7 +1026,7 @@ void RADIO_PrepareTX(void)
}
else
#endif
if (!g_setting_tx_enable || g_serial_config_count_down_500ms > 0)
if (!g_setting_tx_enable || g_serial_config_tick_500ms > 0)
{ // TX is disabled or config upload/download in progress
State = VFO_STATE_TX_DISABLE;
}
@ -1067,7 +1068,7 @@ void RADIO_PrepareTX(void)
{
g_dtmf_is_tx = true;
g_dtmf_call_state = DTMF_CALL_STATE_NONE;
g_dtmf_tx_stop_count_down_500ms = dtmf_txstop_countdown_500ms;
g_dtmf_tx_stop_tick_500ms = dtmf_txstop_500ms;
}
else
{
@ -1078,19 +1079,19 @@ void RADIO_PrepareTX(void)
FUNCTION_Select(FUNCTION_TRANSMIT);
g_tx_timer_count_down_500ms = 0; // no timeout
g_tx_timer_tick_500ms = 0; // no timeout
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (g_alarm_state == ALARM_STATE_OFF)
#endif
{
if (g_eeprom.tx_timeout_timer == 0)
g_tx_timer_count_down_500ms = 60; // 30 sec
g_tx_timer_tick_500ms = 60; // 30 sec
else
if (g_eeprom.tx_timeout_timer < (ARRAY_SIZE(g_sub_menu_tx_timeout) - 1))
g_tx_timer_count_down_500ms = 120 * g_eeprom.tx_timeout_timer; // minutes
g_tx_timer_tick_500ms = 120 * g_eeprom.tx_timeout_timer; // minutes
else
g_tx_timer_count_down_500ms = 120 * 15; // 15 minutes
g_tx_timer_tick_500ms = 120 * 15; // 15 minutes
}
g_tx_timeout_reached = false;

View File

@ -57,23 +57,23 @@ void SystickHandler(void)
g_next_time_slice_500ms = true;
DECREMENT_AND_TRIGGER(g_tx_timer_count_down_500ms, g_tx_timeout_reached);
DECREMENT(g_serial_config_count_down_500ms);
DECREMENT_AND_TRIGGER(g_tx_timer_tick_500ms, g_tx_timeout_reached);
DECREMENT(g_serial_config_tick_500ms);
}
if ((g_global_sys_tick_counter & 3) == 0)
g_next_time_slice_40ms = true;
#ifdef ENABLE_NOAA
DECREMENT(g_noaa_count_down_10ms);
DECREMENT(g_noaa_tick_10ms);
#endif
DECREMENT(g_found_cdcss_count_down_10ms);
DECREMENT(g_found_cdcss_tick_10ms);
DECREMENT(g_found_ctcss_count_down_10ms);
DECREMENT(g_found_ctcss_tick_10ms);
if (g_current_function == FUNCTION_FOREGROUND)
DECREMENT_AND_TRIGGER(g_battery_save_count_down_10ms, g_schedule_power_save);
DECREMENT_AND_TRIGGER(g_battery_save_tick_10ms, g_schedule_power_save);
if (g_current_function == FUNCTION_POWER_SAVE)
DECREMENT_AND_TRIGGER(g_power_save_10ms, g_power_save_expired);
@ -87,27 +87,27 @@ void SystickHandler(void)
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_is_noaa_mode && g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT)
if (g_current_function != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(g_noaa_count_down_10ms, g_schedule_noaa);
DECREMENT_AND_TRIGGER(g_noaa_tick_10ms, g_schedule_noaa);
#endif
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || g_css_scan_mode == CSS_SCAN_MODE_SCANNING)
if (g_current_function != FUNCTION_MONITOR && g_current_function != FUNCTION_TRANSMIT)
DECREMENT(g_scan_pause_10ms);
DECREMENT_AND_TRIGGER(g_tail_tone_elimination_count_down_10ms, g_flag_tail_tone_elimination_complete);
DECREMENT_AND_TRIGGER(g_tail_tone_elimination_tick_10ms, g_flag_tail_tone_elimination_complete);
#ifdef ENABLE_VOICE
DECREMENT_AND_TRIGGER(g_count_down_to_play_next_voice_10ms, g_flag_play_queued_voice);
DECREMENT_AND_TRIGGER(g_tick_to_play_next_voice_10ms, g_flag_play_queued_voice);
#endif
#ifdef ENABLE_FMRADIO
if (g_fm_scan_state != FM_SCAN_OFF && g_current_function != FUNCTION_MONITOR)
if (g_current_function != FUNCTION_TRANSMIT && g_current_function != FUNCTION_RECEIVE)
DECREMENT_AND_TRIGGER(g_fm_play_count_down_10ms, g_schedule_fm);
DECREMENT_AND_TRIGGER(g_fm_play_tick_10ms, g_schedule_fm);
#endif
#ifdef ENABLE_VOX
DECREMENT(g_vox_stop_count_down_10ms);
DECREMENT(g_vox_stop_10ms);
#endif
DECREMENT(g_boot_counter_10ms);

View File

@ -31,7 +31,7 @@ void UI_DisplayAircopy(void)
const uint8_t errors = g_aircopy_rx_errors_fsk_crc + g_aircopy_rx_errors_magic + g_aircopy_rx_errors_crc;
char str[17];
if (g_screen_to_display != DISPLAY_AIRCOPY)
if (g_current_display_screen != DISPLAY_AIRCOPY)
return;
// clear screen/display buffer

View File

@ -18,6 +18,7 @@
#include "app/fm.h"
#include "driver/backlight.h"
#include "driver/bk1080.h"
#include "driver/st7565.h"
#include "external/printf/printf.h"
#include "misc.h"
@ -30,7 +31,7 @@
void UI_DisplayFM(void)
{
unsigned int i;
char String[16];
char str[22];
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
@ -38,8 +39,8 @@ void UI_DisplayFM(void)
if (g_eeprom.key_lock && g_keypad_locked > 0)
{ // tell user how to unlock the keyboard
backlight_turn_on(0);
UI_PrintString("Long press #", 0, LCD_WIDTH, 1, 8);
UI_PrintString("to unlock", 0, LCD_WIDTH, 3, 8);
UI_PrintString("Long press #", 0, LCD_WIDTH - 1, 1, 8);
UI_PrintString("to unlock", 0, LCD_WIDTH - 1, 3, 8);
ST7565_BlitFullScreen();
return;
}
@ -48,7 +49,7 @@ void UI_DisplayFM(void)
// *************************************
// upper text line
UI_PrintString("FM", 0, 127, 0, 12);
UI_PrintString("FM", 0, LCD_WIDTH - 1, 0, 12);
// *************************************
// middle text line
@ -56,16 +57,16 @@ void UI_DisplayFM(void)
if (g_ask_to_save)
{
const unsigned int freq = g_eeprom.fm_frequency_playing;
sprintf(String, "SAVE %u.%u ?", freq / 10, freq % 10);
sprintf(str, "SAVE %u.%u ?", freq / 10, freq % 10);
}
else
if (g_ask_to_delete)
{
strcpy(String, "DELETE ?");
strcpy(str, "DELETE ?");
}
else
{
memset(String, 0, sizeof(String));
memset(str, 0, sizeof(str));
if (g_fm_scan_state == FM_SCAN_OFF)
{
@ -75,43 +76,43 @@ void UI_DisplayFM(void)
{
if (g_eeprom.fm_frequency_playing == g_fm_channels[i])
{
sprintf(String, "VFO (CH %u)", 1 + i);
sprintf(str, "VFO (CH %u)", 1 + i);
break;
}
}
if (i >= ARRAY_SIZE(g_fm_channels))
strcpy(String, "VFO");
strcpy(str, "VFO");
}
else
sprintf(String, "CH %u", 1 + g_eeprom.fm_selected_channel);
sprintf(str, "CH %u", 1 + g_eeprom.fm_selected_channel);
}
else
if (!g_fm_auto_scan)
strcpy(String, "FREQ SCAN");
strcpy(str, "FREQ SCAN");
else
sprintf(String, "A-SCAN %2u", 1 + g_fm_channel_position);
sprintf(str, "A-SCAN %2u", 1 + g_fm_channel_position);
}
UI_PrintString(String, 0, 127, 2, 10);
UI_PrintString(str, 0, LCD_WIDTH - 1, 2, 10);
// *************************************
// lower text line
memset(String, 0, sizeof(String));
memset(str, 0, sizeof(str));
if (g_ask_to_save)
{ // channel mode
const unsigned int chan = g_fm_channel_position;
const uint32_t freq = g_fm_channels[chan];
UI_GenerateChannelString(String, chan, ' ');
UI_GenerateChannelString(str, chan, ' ');
if (FM_CheckValidChannel(chan))
sprintf(String + strlen(String), " (%u.%u)", freq / 10, freq % 10);
sprintf(str + strlen(str), " (%u.%u)", freq / 10, freq % 10);
}
else
if (g_eeprom.fm_channel_mode && g_input_box_index > 0)
{ // user is entering a channel number
UI_GenerateChannelString(String, g_fm_channel_position, ' ');
UI_GenerateChannelString(str, g_fm_channel_position, ' ');
}
else
if (!g_ask_to_delete)
@ -119,8 +120,12 @@ void UI_DisplayFM(void)
if (g_input_box_index == 0)
{ // frequency mode
const uint32_t freq = g_eeprom.fm_frequency_playing;
NUMBER_ToDigits(freq * 10000, String);
UI_DisplayFrequency(String, 23, 4, false, true);
NUMBER_ToDigits(freq * 10000, str);
#ifdef ENABLE_TRIM_TRAILING_ZEROS
UI_DisplayFrequency(str, 30, 4, false, true);
#else
UI_DisplayFrequency(str, 23, 4, false, true);
#endif
}
else
{ // user is entering a frequency
@ -131,10 +136,23 @@ void UI_DisplayFM(void)
{ // delete channel
const uint32_t chan = g_eeprom.fm_selected_channel;
const uint32_t freq = g_fm_channels[chan];
sprintf(String, "CH %u (%u.%u)", 1 + chan, freq / 10, freq % 10);
sprintf(str, "CH %u (%u.%u)", 1 + chan, freq / 10, freq % 10);
}
UI_PrintString(String, 0, 127, 4, (strlen(String) >= 8) ? 8 : 10);
UI_PrintString(str, 0, LCD_WIDTH - 1, 4, (strlen(str) >= 8) ? 8 : 10);
// *************************************
{
const uint16_t val_07 = BK1080_ReadRegister(0x07);
const uint16_t val_0A = BK1080_ReadRegister(0x0A);
sprintf(str, "%s %s %2udBuV %2u",
((val_0A >> 9) & 1u) ? "STE" : "ste",
((val_0A >> 8) & 1u) ? "ST" : "st",
(val_0A >> 0) & 0x00ff,
(val_07 >> 0) & 0x000f);
UI_PrintStringSmall(str, 0, LCD_WIDTH, 6);
}
// *************************************

View File

@ -86,7 +86,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
{
unsigned int timeout_secs = 0;
if (g_current_function != FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
if (g_current_function != FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
return false;
if (g_center_line != CENTER_LINE_NONE && g_center_line != CENTER_LINE_TX_TIMEOUT)
@ -100,7 +100,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
else
timeout_secs = 60 * 15; // 15 minutes
if (timeout_secs == 0 || g_tx_timer_count_down_500ms == 0)
if (timeout_secs == 0 || g_tx_timer_tick_500ms == 0)
return false;
{
@ -108,7 +108,7 @@ void draw_bar(uint8_t *line, const int len, const int max_width)
const unsigned int txt_width = 7 * 6; // 6 text chars
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
const unsigned int bar_width = LCD_WIDTH - 1 - bar_x;
const unsigned int secs = g_tx_timer_count_down_500ms / 2;
const unsigned int secs = g_tx_timer_tick_500ms / 2;
const unsigned int level = ((secs * bar_width) + (timeout_secs / 2)) / timeout_secs; // with rounding
// const unsigned int level = (((timeout_secs - secs) * bar_width) + (timeout_secs / 2)) / timeout_secs; // with rounding
const unsigned int len = (level <= bar_width) ? level : bar_width;
@ -178,7 +178,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
bool UI_DisplayAudioBar(const bool now)
{
if (g_current_function != FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
if (g_current_function != FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
return false;
if (g_center_line != CENTER_LINE_NONE && g_center_line != CENTER_LINE_AUDIO_BAR)
@ -198,7 +198,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
const unsigned int txt_width = 7 * 3; // 3 text chars
const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph
const unsigned int bar_width = LCD_WIDTH - 1 - bar_x;
const unsigned int secs = g_tx_timer_count_down_500ms / 2;
const unsigned int secs = g_tx_timer_tick_500ms / 2;
uint8_t *p_line = g_frame_buffer[line];
char s[16];
@ -272,7 +272,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
#endif
if (g_current_function == FUNCTION_TRANSMIT ||
g_screen_to_display != DISPLAY_MAIN ||
g_current_display_screen != DISPLAY_MAIN ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return false; // display is in use
@ -381,7 +381,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo)
return; // display is in use
#endif
if (g_current_function == FUNCTION_TRANSMIT || g_screen_to_display != DISPLAY_MAIN)
if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN)
return; // display is in use
p_line = g_frame_buffer[Line - 1];
@ -448,7 +448,7 @@ void UI_DisplayMain(void)
// clear the screen
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
if (g_serial_config_count_down_500ms > 0)
if (g_serial_config_tick_500ms > 0)
{
backlight_turn_on(10); // 5 seconds
UI_PrintString("UART", 0, LCD_WIDTH, 1, 8);
@ -910,7 +910,7 @@ void UI_DisplayMain(void)
}
if (g_center_line == CENTER_LINE_NONE &&
g_screen_to_display == DISPLAY_MAIN &&
g_current_display_screen == DISPLAY_MAIN &&
g_dtmf_call_state == DTMF_CALL_STATE_NONE)
{ // we're free to use the middle line
@ -979,7 +979,7 @@ void UI_DisplayMain(void)
const unsigned int len = strlen(g_dtmf_rx_live);
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return;
g_center_line = CENTER_LINE_DTMF_DEC;
@ -994,7 +994,7 @@ void UI_DisplayMain(void)
const unsigned int len = g_dtmf_rx_index;
const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return;
g_center_line = CENTER_LINE_DTMF_DEC;
@ -1009,7 +1009,7 @@ void UI_DisplayMain(void)
else
if (g_charging_with_type_c)
{ // show the battery charge state
if (g_screen_to_display != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return;
g_center_line = CENTER_LINE_CHARGE_DATA;

View File

@ -34,7 +34,7 @@ void UI_DisplaySearch(void)
char String[17];
bool text_centered = false;
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
return;
// clear display buffer

View File

@ -102,7 +102,7 @@ void UI_DisplayStatus(const bool test_display)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF || test_display)
{
// don't display this if in search mode
if (g_screen_to_display != DISPLAY_SEARCH)
if (g_current_display_screen != DISPLAY_SEARCH)
{
if (g_scan_next_channel <= USER_CHANNEL_LAST)
{ // channel mode
@ -145,7 +145,7 @@ void UI_DisplayStatus(const bool test_display)
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)
g_current_display_screen == DISPLAY_SEARCH)
{
memcpy(line + x, BITMAP_TDR_HOLDING, sizeof(BITMAP_TDR_HOLDING));
}

View File

@ -35,7 +35,7 @@
#include "ui/search.h"
#include "ui/ui.h"
gui_display_type_t g_screen_to_display;
gui_display_type_t g_current_display_screen;
gui_display_type_t g_request_display_screen = DISPLAY_INVALID;
uint8_t g_ask_for_confirmation;
bool g_ask_to_save;
@ -45,7 +45,7 @@ void GUI_DisplayScreen(void)
{
g_update_display = false;
switch (g_screen_to_display)
switch (g_current_display_screen)
{
case DISPLAY_MAIN:
UI_DisplayMain();
@ -81,7 +81,7 @@ void GUI_SelectNextDisplay(gui_display_type_t Display)
if (Display == DISPLAY_INVALID)
return;
if (g_screen_to_display != Display)
if (g_current_display_screen != Display)
{
DTMF_clear_input_box();
@ -100,6 +100,6 @@ void GUI_SelectNextDisplay(gui_display_type_t Display)
g_update_status = true;
}
g_screen_to_display = Display;
g_current_display_screen = Display;
g_update_display = true;
}

View File

@ -31,7 +31,7 @@ enum gui_display_type_e
};
typedef enum gui_display_type_e gui_display_type_t;
extern gui_display_type_t g_screen_to_display;
extern gui_display_type_t g_current_display_screen;
extern gui_display_type_t g_request_display_screen;
extern uint8_t g_ask_for_confirmation;
extern bool g_ask_to_save;