0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

renames to reduce confusion

This commit is contained in:
OneOfEleven
2023-10-23 14:02:54 +01:00
parent 74f52f9d14
commit 3b4178d59d
22 changed files with 177 additions and 129 deletions

117
app/app.c
View File

@ -90,9 +90,9 @@ static void APP_update_rssi(const int vfo)
UI_update_rssi(rssi, vfo);
}
static void APP_check_for_incoming_rx(void)
static void APP_check_for_new_receive(void)
{
if (!g_squelch_lost)
if (!g_squelch_open)
return;
// squelch is open
@ -139,23 +139,22 @@ static void APP_check_for_incoming_rx(void)
}
g_rx_reception_mode = RX_MODE_DETECTED;
g_scan_pause_mode = true; // 1of11
done:
if (g_current_function != FUNCTION_INCOMING)
if (g_current_function != FUNCTION_NEW_RECEIVE)
{
FUNCTION_Select(FUNCTION_INCOMING);
FUNCTION_Select(FUNCTION_NEW_RECEIVE);
APP_update_rssi(g_eeprom.rx_vfo);
g_update_rssi = true;
}
}
static void APP_process_incoming_rx(void)
static void APP_process_new_receive(void)
{
bool flag;
if (!g_squelch_lost)
if (!g_squelch_open)
{ // squelch is closed
if (g_dtmf_rx_index > 0)
@ -166,6 +165,7 @@ static void APP_process_incoming_rx(void)
FUNCTION_Select(FUNCTION_FOREGROUND);
g_update_display = true;
}
return;
}
@ -243,7 +243,7 @@ static void APP_process_rx(void)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF && IS_FREQ_CHANNEL(g_scan_next_channel))
{
if (g_squelch_lost)
if (g_squelch_open)
return;
Mode = END_OF_RX_MODE_END;
@ -261,7 +261,7 @@ static void APP_process_rx(void)
{
g_found_ctcss = false;
g_found_cdcss = false;
Mode = END_OF_RX_MODE_END;
Mode = END_OF_RX_MODE_END;
goto Skip;
}
break;
@ -272,13 +272,13 @@ static void APP_process_rx(void)
{
g_found_ctcss = false;
g_found_cdcss = false;
Mode = END_OF_RX_MODE_END;
Mode = END_OF_RX_MODE_END;
goto Skip;
}
break;
}
if (g_squelch_lost)
if (g_squelch_open)
{
if (!g_end_of_rx_detected_maybe && IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
{
@ -340,8 +340,10 @@ static void APP_process_rx(void)
}
}
else
{
Mode = END_OF_RX_MODE_END;
}
if (!g_end_of_rx_detected_maybe &&
Mode == END_OF_RX_MODE_SKIP &&
g_next_time_slice_40ms &&
@ -376,14 +378,14 @@ Skip:
{
switch (g_eeprom.scan_resume_mode)
{
case SCAN_RESUME_TO:
case SCAN_RESUME_TIME:
break;
case SCAN_RESUME_CO:
case SCAN_RESUME_CARRIER:
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
break;
case SCAN_RESUME_SE:
case SCAN_RESUME_SEARCH:
APP_stop_scan();
break;
}
@ -399,7 +401,7 @@ Skip:
g_tail_tone_elimination_count_down_10ms = 20;
g_flag_tail_tone_elimination_complete = false;
g_end_of_rx_detected_maybe = true;
g_enable_speaker = false;
g_speaker_enabled = false;
}
break;
}
@ -413,7 +415,7 @@ static void APP_process_function(void)
switch (g_current_function)
{
case FUNCTION_FOREGROUND:
APP_check_for_incoming_rx();
APP_check_for_new_receive();
break;
case FUNCTION_TRANSMIT:
@ -421,8 +423,8 @@ static void APP_process_function(void)
backlight_turn_on(backlight_tx_rx_time_500ms);
break;
case FUNCTION_INCOMING:
APP_process_incoming_rx();
case FUNCTION_NEW_RECEIVE:
APP_process_new_receive();
case FUNCTION_MONITOR:
break;
@ -433,7 +435,7 @@ static void APP_process_function(void)
case FUNCTION_POWER_SAVE:
if (!g_rx_idle_mode)
APP_check_for_incoming_rx();
APP_check_for_new_receive();
break;
case FUNCTION_PANADAPTER:
@ -465,13 +467,17 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
g_vfo_rssi_bar_level[(chan + 1) & 1u] = 0;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = true;
g_speaker_enabled = true;
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{ // we're RF scanning
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
switch (g_eeprom.scan_resume_mode)
{
case SCAN_RESUME_TO:
case SCAN_RESUME_TIME:
if (!g_scan_pause_mode)
{
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
@ -479,11 +485,14 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
}
break;
case SCAN_RESUME_CO:
case SCAN_RESUME_SE:
case SCAN_RESUME_CARRIER:
case SCAN_RESUME_SEARCH:
g_scan_pause_10ms = 0;
break;
}
#pragma GCC diagnostic pop
}
#ifdef ENABLE_NOAA
@ -610,7 +619,7 @@ void APP_stop_scan(void)
g_scan_pause_10ms > (200 / 10) ||
g_current_function == FUNCTION_RECEIVE ||
g_current_function == FUNCTION_MONITOR ||
g_current_function == FUNCTION_INCOMING)
g_current_function == FUNCTION_NEW_RECEIVE)
{ // stay where we are
g_scan_pause_mode = false;
g_scan_restore_channel = 0xff;
@ -953,16 +962,24 @@ void APP_process_radio_interrupts(void)
}
#endif
if (interrupt_bits & BK4819_REG_02_SQUELCH_LOST)
if (interrupt_bits & BK4819_REG_02_SQUELCH_CLOSED)
{
g_squelch_lost = true;
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
g_squelch_open = false;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("squelch found (closed)\r\n");
#endif
}
if (interrupt_bits & BK4819_REG_02_SQUELCH_FOUND)
if (interrupt_bits & BK4819_REG_02_SQUELCH_OPENED)
{
g_squelch_lost = false;
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off
// BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
g_squelch_open = true;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("squelch lost (opened)\r\n");
#endif
}
}
}
@ -1114,31 +1131,43 @@ void APP_process(void)
if (g_voice_write_index == 0)
#endif
{
if ((g_current_function == FUNCTION_FOREGROUND ||
g_current_function == FUNCTION_INCOMING) && // TODO: check me
if ((g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_NEW_RECEIVE) && // TODO: check me
g_screen_to_display != DISPLAY_SEARCH &&
g_scan_state_dir != SCAN_STATE_DIR_OFF &&
g_scan_pause_10ms == 0 &&
!g_ptt_is_pressed)
{ // RF scanning
// TODO: check to see if signal stays present for minimum time before pausing
if (IS_FREQ_CHANNEL(g_scan_next_channel))
{
if (g_current_function == FUNCTION_INCOMING)
if (g_current_function == FUNCTION_NEW_RECEIVE)
{
APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
}
else
APP_next_freq(); // switch to next frequency
{ // switch to next frequency
g_scan_pause_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
APP_next_freq();
}
}
else
{
if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_INCOMING)
if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE)
{
APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
}
else
APP_next_channel(); // switch to next channel
{ // switch to next channel
g_scan_pause_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
APP_next_channel();
}
}
g_scan_pause_mode = false;
g_rx_reception_mode = RX_MODE_NONE;
}
}
@ -1711,7 +1740,7 @@ void APP_time_slice_10ms(void)
SYSTEM_DelayMs(2);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = true;
g_speaker_enabled = true;
g_alarm_tone_counter_10ms = 0;
}
}
@ -2339,7 +2368,7 @@ void APP_time_slice_500ms(void)
static void APP_alarm_off(void)
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = false;
g_speaker_enabled = false;
if (g_eeprom.alarm_mode == ALARM_MODE_TONE)
{
@ -2619,7 +2648,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = false;
g_speaker_enabled = false;
BK4819_ExitDTMF_TX(false);
@ -2634,7 +2663,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
if (g_eeprom.dtmf_side_tone)
{ // user will here the DTMF tones in speaker
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = true;
g_speaker_enabled = true;
}
BK4819_DisableScramble();

View File

@ -442,7 +442,7 @@ bool DTMF_Reply(void)
if (g_eeprom.dtmf_side_tone)
{ // the user will also hear the transmitted tones
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = true;
g_speaker_enabled = true;
}
SYSTEM_DelayMs(Delay);
@ -459,7 +459,7 @@ bool DTMF_Reply(void)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = false;
g_speaker_enabled = false;
BK4819_ExitDTMF_TX(false);

View File

@ -101,7 +101,7 @@ void FM_TurnOff(void)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = false;
g_speaker_enabled = false;
BK1080_Init(0, false);
@ -124,7 +124,7 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool flag)
{
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = false;
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;
@ -171,7 +171,7 @@ void FM_PlayAndUpdate(void)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = true;
g_speaker_enabled = true;
}
int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
@ -660,7 +660,7 @@ void FM_Play(void)
g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = true;
g_speaker_enabled = true;
GUI_SelectNextDisplay(DISPLAY_FM);
return;
@ -695,6 +695,6 @@ void FM_Start(void)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
g_enable_speaker = true;
g_speaker_enabled = true;
g_update_status = true;
}

View File

@ -40,6 +40,19 @@
#include "ui/ui.h"
#include "ui/menu.h"
bool scanning_paused(void)
{
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) &&
g_scan_pause_10ms > 0 &&
g_scan_pause_10ms <= (200 / 10) &&
!g_scan_pause_mode)
{ // scanning isn't paused
return false;
}
return true;
}
void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting
@ -58,10 +71,7 @@ void toggle_chan_scanlist(void)
return;
}
if (g_scan_state_dir != SCAN_STATE_DIR_OFF &&
g_scan_pause_10ms > 0 &&
g_scan_pause_10ms <= (200 / 10) &&
!g_scan_pause_mode)
if (!scanning_paused())
{ // scanning isn't paused
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
@ -90,28 +100,31 @@ void toggle_chan_scanlist(void)
#ifdef ENABLE_COPY_CHAN_TO_VFO_TO_CHAN
void MAIN_copy_mem_vfo_mem(void)
{
{
//const unsigned int vfo = get_RX_VFO();
const unsigned int vfo = g_eeprom.tx_vfo;
if (g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_eeprom.dual_watch != DUAL_WATCH_OFF ||
!g_eeprom.vfo_open)
{ // scanning
if (g_css_scan_mode != CSS_SCAN_MODE_OFF || !g_eeprom.vfo_open)
{ // scanning or VFO disabled
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (!scanning_paused())
{ // RF scanning
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (IS_USER_CHANNEL(g_eeprom.screen_channel[vfo]))
{ // copy channel to VFO, then swap to the VFO
const unsigned int channel = FREQ_CHANNEL_FIRST + g_eeprom.vfo_info[vfo].band;
g_eeprom.screen_channel[vfo] = channel;
g_eeprom.vfo_info[vfo].channel_save = channel;
g_eeprom.tx_vfo = vfo;
RADIO_select_vfos();
RADIO_ApplyOffset(g_tx_vfo);
RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo);
@ -121,17 +134,17 @@ void toggle_chan_scanlist(void)
g_tx_vfo->freq_in_channel = BOARD_find_channel(g_tx_vfo->freq_config_tx.frequency);
g_request_save_vfo = true;
g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP;
//g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
g_update_status = true;
g_update_display = true;
}
else
if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[vfo]))
{ // copy VFO to a channel
// search the channels to see if the frequency is already present
unsigned int chan = BOARD_find_channel(g_eeprom.vfo_info[vfo].p_tx->frequency);
if (chan > USER_CHANNEL_LAST)
@ -141,7 +154,7 @@ void toggle_chan_scanlist(void)
if (!RADIO_CheckValidChannel(chan, false, vfo))
break;
}
g_screen_to_display = DISPLAY_INVALID;
GUI_SelectNextDisplay(DISPLAY_MENU);
g_menu_cursor = MENU_MEM_SAVE;
@ -151,18 +164,18 @@ void toggle_chan_scanlist(void)
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("vfo to mem %u\r\n", chan);
#endif
g_sub_menu_selection = chan;
g_flag_refresh_menu = false;
g_screen_to_display = DISPLAY_MENU;
g_update_display = false;
UI_DisplayMenu();
}
#ifdef ENABLE_VOICE
g_another_voice_id = VOICE_ID_MENU;
#endif
g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP;
}
}
@ -683,7 +696,7 @@ void MAIN_Key_MENU(const bool key_pressed, const bool key_held)
{ // key just pressed
AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL);
}
if (key_held)
{ // menu key held down (long press)
@ -834,19 +847,19 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
#endif
g_tx_vfo->freq_config_tx.frequency = g_tx_vfo->freq_config_rx.frequency;
// find the first channel that contains this frequency
g_tx_vfo->freq_in_channel = BOARD_find_channel(g_tx_vfo->freq_config_rx.frequency);
// only update eeprom when the key is released - saves a LOT of wear and tear on the little eeprom
SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, 1);
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("save chan\r\n");
#endif
}
}
if (key_held || !key_pressed)
{ // long press

View File

@ -447,7 +447,7 @@ void SEARCH_Start(void)
g_cdcss_code_type = 0;
g_ctcss_lost = false;
g_squelch_lost = false;
g_squelch_open = false;
g_search_delay_10ms = scan_freq_css_delay_10ms;
g_search_css_result_type = CODE_TYPE_NONE;
g_search_css_result_code = 0xff;