mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 06:39:49 +03:00
ctcss phase stuff + fast manual freq up/dn scanning update
This commit is contained in:
279
app/app.c
279
app/app.c
@ -92,8 +92,7 @@ static void APP_update_rssi(const int vfo)
|
||||
|
||||
g_current_rssi[vfo] = rssi;
|
||||
|
||||
// if (g_squelch_open || g_monitor_enabled)
|
||||
UI_update_rssi(rssi, vfo);
|
||||
UI_update_rssi(rssi, vfo);
|
||||
}
|
||||
|
||||
static void APP_check_for_new_receive(void)
|
||||
@ -109,7 +108,7 @@ static void APP_check_for_new_receive(void)
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF && g_rx_reception_mode == RX_MODE_NONE)
|
||||
{ // CTCSS/DTS scanning
|
||||
|
||||
g_scan_pause_tick_10ms = scan_pause_code_10ms;
|
||||
g_scan_pause_tick_10ms = scan_pause_code_10ms;
|
||||
g_scan_pause_time_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
}
|
||||
@ -121,7 +120,7 @@ static void APP_check_for_new_receive(void)
|
||||
if (g_is_noaa_mode)
|
||||
{
|
||||
g_noaa_tick_10ms = noaa_tick_3_10ms;
|
||||
g_schedule_noaa = false;
|
||||
g_schedule_noaa = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -150,7 +149,7 @@ static void APP_check_for_new_receive(void)
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
|
||||
done:
|
||||
// if (g_current_function != FUNCTION_NEW_RECEIVE)
|
||||
if (g_current_function != FUNCTION_NEW_RECEIVE)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_NEW_RECEIVE);
|
||||
|
||||
@ -162,11 +161,10 @@ done:
|
||||
//BK4819_WriteRegister(0x59, (1u << 12) | fsk_reg59);
|
||||
}
|
||||
#endif
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
|
||||
g_update_rssi = true;
|
||||
}
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
g_update_rssi = true;
|
||||
// }
|
||||
}
|
||||
|
||||
static void APP_process_new_receive(void)
|
||||
@ -194,14 +192,14 @@ static void APP_process_new_receive(void)
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_tick_10ms > 0)
|
||||
{
|
||||
g_noaa_tick_10ms = 0;
|
||||
flag = true;
|
||||
flag = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_ctcss_lost && g_current_code_type == CODE_TYPE_CONTINUOUS_TONE)
|
||||
{
|
||||
flag = true;
|
||||
g_found_ctcss = false;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (g_cdcss_lost && g_cdcss_code_type == CDCSS_POSITIVE_CODE && (g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL))
|
||||
@ -229,7 +227,7 @@ static void APP_process_new_receive(void)
|
||||
if (g_rx_reception_mode == RX_MODE_DETECTED)
|
||||
{
|
||||
g_dual_watch_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_rx_reception_mode = RX_MODE_LISTENING;
|
||||
g_rx_reception_mode = RX_MODE_LISTENING;
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
@ -269,7 +267,7 @@ static void APP_process_rx(void)
|
||||
case SCAN_RESUME_TIME: // stay only for a limited time
|
||||
break;
|
||||
case SCAN_RESUME_CARRIER: // stay untill the carrier goes away
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_time_mode = false;
|
||||
break;
|
||||
case SCAN_RESUME_STOP: // stop scan once we find any signal
|
||||
@ -321,11 +319,11 @@ static void APP_process_rx(void)
|
||||
switch (g_current_code_type)
|
||||
{
|
||||
case CODE_TYPE_NONE:
|
||||
if (g_eeprom.squelch_level)
|
||||
if (g_eeprom.squelch_level > 0)
|
||||
{
|
||||
if (g_cxcss_tail_found)
|
||||
{
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
g_cxcss_tail_found = false;
|
||||
}
|
||||
}
|
||||
@ -339,13 +337,13 @@ static void APP_process_rx(void)
|
||||
else
|
||||
if (!g_found_ctcss)
|
||||
{
|
||||
g_found_ctcss = true;
|
||||
g_found_ctcss = true;
|
||||
g_found_ctcss_tick_10ms = 100; // 1 sec
|
||||
}
|
||||
|
||||
if (g_cxcss_tail_found)
|
||||
{
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
g_cxcss_tail_found = false;
|
||||
}
|
||||
break;
|
||||
@ -359,7 +357,7 @@ static void APP_process_rx(void)
|
||||
else
|
||||
if (!g_found_cdcss)
|
||||
{
|
||||
g_found_cdcss = true;
|
||||
g_found_cdcss = true;
|
||||
g_found_cdcss_tick_10ms = 100; // 1 sec
|
||||
}
|
||||
|
||||
@ -412,10 +410,9 @@ Skip:
|
||||
break;
|
||||
|
||||
case END_OF_RX_MODE_TTE:
|
||||
|
||||
if (g_eeprom.tail_note_elimination)
|
||||
{
|
||||
if (!g_squelch_open && !g_monitor_enabled)
|
||||
if (!g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_tail_tone_elimination_tick_10ms = 20; // 200ms
|
||||
@ -470,6 +467,11 @@ bool APP_start_listening(void)
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
{ // we're RF scanning
|
||||
|
||||
g_rx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
if (IS_FREQ_CHANNEL(g_scan_next_channel))
|
||||
g_rx_vfo->freq_in_channel = BOARD_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
|
||||
switch (g_eeprom.scan_resume_mode)
|
||||
{
|
||||
case SCAN_RESUME_TIME:
|
||||
@ -629,6 +631,9 @@ void APP_stop_scan(void)
|
||||
|
||||
g_rx_vfo->freq_config_rx.frequency = g_scan_restore_frequency;
|
||||
|
||||
// find the first channel that contains this frequency
|
||||
g_rx_vfo->freq_in_channel = BOARD_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
|
||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
RADIO_setup_registers(true);
|
||||
@ -670,6 +675,8 @@ static void APP_next_freq(void)
|
||||
|
||||
g_rx_vfo->freq_config_rx.frequency = frequency;
|
||||
|
||||
g_rx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("APP_next_freq %u %u\r\n", frequency, new_band);
|
||||
#endif
|
||||
@ -864,81 +871,111 @@ void APP_process_radio_interrupts(void)
|
||||
if (g_current_display_screen == DISPLAY_SEARCH)
|
||||
return;
|
||||
|
||||
while (BK4819_ReadRegister(0x0C) & (1u << 0))
|
||||
{ // BK chip interrupt request
|
||||
while (1)
|
||||
{ // BK4819 chip interrupt request
|
||||
|
||||
uint16_t interrupt_bits;
|
||||
uint16_t int_bits;
|
||||
|
||||
const uint16_t reg_c = BK4819_ReadRegister(0x0C);
|
||||
if ((reg_c & 1u) == 0)
|
||||
break;
|
||||
|
||||
BK4819_WriteRegister(0x02, 0);
|
||||
interrupt_bits = BK4819_ReadRegister(0x02);
|
||||
int_bits = BK4819_ReadRegister(0x02);
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("reg_c int_bits %04X\r\n", reg_c, int_bits);
|
||||
#endif
|
||||
|
||||
if (int_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
|
||||
{ // save the RX'ed DTMF character
|
||||
const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
|
||||
if (c != 0xff)
|
||||
if (c != 0xff && g_current_function != FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (g_current_function != FUNCTION_TRANSMIT)
|
||||
if (g_setting_live_dtmf_decoder)
|
||||
{
|
||||
if (g_setting_live_dtmf_decoder)
|
||||
{
|
||||
size_t len = strlen(g_dtmf_rx_live);
|
||||
if (len >= (sizeof(g_dtmf_rx_live) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx_live[0], &g_dtmf_rx_live[1], sizeof(g_dtmf_rx_live) - 1);
|
||||
len--;
|
||||
}
|
||||
g_dtmf_rx_live[len++] = c;
|
||||
g_dtmf_rx_live[len] = 0;
|
||||
g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it
|
||||
g_update_display = true;
|
||||
size_t len = strlen(g_dtmf_rx_live);
|
||||
if (len >= (sizeof(g_dtmf_rx_live) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx_live[0], &g_dtmf_rx_live[1], sizeof(g_dtmf_rx_live) - 1);
|
||||
len--;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
|
||||
#else
|
||||
if (g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
{
|
||||
if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx[0], &g_dtmf_rx[1], sizeof(g_dtmf_rx) - 1);
|
||||
g_dtmf_rx_index--;
|
||||
}
|
||||
g_dtmf_rx[g_dtmf_rx_index++] = c;
|
||||
g_dtmf_rx[g_dtmf_rx_index] = 0;
|
||||
g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it
|
||||
g_dtmf_rx_pending = true;
|
||||
|
||||
DTMF_HandleRequest();
|
||||
g_dtmf_rx_live[len++] = c;
|
||||
g_dtmf_rx_live[len] = 0;
|
||||
g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
|
||||
#else
|
||||
if (g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
{
|
||||
if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx[0], &g_dtmf_rx[1], sizeof(g_dtmf_rx) - 1);
|
||||
g_dtmf_rx_index--;
|
||||
}
|
||||
g_dtmf_rx[g_dtmf_rx_index++] = c;
|
||||
g_dtmf_rx[g_dtmf_rx_index] = 0;
|
||||
g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it
|
||||
g_dtmf_rx_pending = true;
|
||||
|
||||
DTMF_HandleRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CxCSS_TAIL)
|
||||
g_cxcss_tail_found = true;
|
||||
if (int_bits & BK4819_REG_02_CxCSS_TAIL)
|
||||
{
|
||||
g_cxcss_tail_found = true;
|
||||
g_ctcss_tail_phase_shift_rx = (reg_c >> 12) & 3u;
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CDCSS_LOST)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("cxcss tail %u\r\n", g_ctcss_tail_phase_shift_rx);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (int_bits & BK4819_REG_02_CDCSS_LOST)
|
||||
{
|
||||
g_cdcss_lost = true;
|
||||
g_cdcss_code_type = BK4819_get_CDCSS_code_type();
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("cdcss lost %u\r\n", g_cdcss_code_type);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CDCSS_FOUND)
|
||||
if (int_bits & BK4819_REG_02_CDCSS_FOUND)
|
||||
{
|
||||
g_cdcss_lost = false;
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CTCSS_LOST)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("cdcss found\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (int_bits & BK4819_REG_02_CTCSS_LOST)
|
||||
{
|
||||
g_ctcss_lost = true;
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CTCSS_FOUND)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("cdcss lost\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (int_bits & BK4819_REG_02_CTCSS_FOUND)
|
||||
{
|
||||
g_ctcss_lost = false;
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
MDC1200_process_rx(interrupt_bits);
|
||||
#endif
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("ctcss found\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
if (interrupt_bits & BK4819_REG_02_VOX_LOST)
|
||||
if (int_bits & BK4819_REG_02_VOX_LOST)
|
||||
{
|
||||
g_vox_lost = true;
|
||||
g_vox_pause_tick_10ms = 10;
|
||||
@ -960,14 +997,14 @@ void APP_process_radio_interrupts(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_VOX_FOUND)
|
||||
if (int_bits & BK4819_REG_02_VOX_FOUND)
|
||||
{
|
||||
g_vox_lost = false;
|
||||
g_vox_pause_tick_10ms = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_SQUELCH_CLOSED)
|
||||
if (int_bits & BK4819_REG_02_SQUELCH_CLOSED)
|
||||
{
|
||||
g_squelch_open = false;
|
||||
|
||||
@ -986,7 +1023,7 @@ void APP_process_radio_interrupts(void)
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_SQUELCH_OPENED)
|
||||
if (int_bits & BK4819_REG_02_SQUELCH_OPENED)
|
||||
{
|
||||
g_squelch_open = true;
|
||||
|
||||
@ -1002,6 +1039,10 @@ void APP_process_radio_interrupts(void)
|
||||
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
MDC1200_process_rx(int_bits);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,13 +1057,13 @@ void APP_end_tx(void)
|
||||
//if (g_eeprom.tail_note_elimination && g_eeprom.repeater_tail_tone_elimination > 0)
|
||||
if (g_eeprom.tail_note_elimination)
|
||||
{ // send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
}
|
||||
#if 1
|
||||
else
|
||||
{ // TX a short blank carrier after disabling the CTCSS/CDCSS
|
||||
// this gives the receivers time to mute their RX audio before we drop carrier
|
||||
BK4819_ExitSubAu();
|
||||
BK4819_disable_sub_audible();
|
||||
SYSTEM_DelayMs(200);
|
||||
}
|
||||
#endif
|
||||
@ -1031,10 +1072,7 @@ void APP_end_tx(void)
|
||||
RADIO_setup_registers(false);
|
||||
|
||||
if (g_monitor_enabled)
|
||||
APP_start_listening();
|
||||
|
||||
if (g_squelch_open || g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
@ -1089,16 +1127,14 @@ void APP_end_tx(void)
|
||||
APP_end_tx();
|
||||
|
||||
if (g_eeprom.repeater_tail_tone_elimination == 0)
|
||||
{
|
||||
//if (g_current_function != FUNCTION_FOREGROUND)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
else
|
||||
g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10;
|
||||
}
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
|
||||
g_flag_end_tx = false;
|
||||
}
|
||||
return;
|
||||
@ -1124,7 +1160,7 @@ void APP_end_tx(void)
|
||||
// called every 10ms
|
||||
void APP_check_keys(void)
|
||||
{
|
||||
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && (g_serial_config_tick_500ms == 0) && g_setting_tx_enable;
|
||||
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT);
|
||||
|
||||
key_code_t key;
|
||||
|
||||
@ -1138,43 +1174,48 @@ void APP_check_keys(void)
|
||||
|
||||
if (ptt_pressed)
|
||||
{ // PTT pressed
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (!g_setting_radio_disabled)
|
||||
#endif
|
||||
|
||||
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_setting_tx_enable)
|
||||
{
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (!g_ptt_is_pressed && g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
#else
|
||||
if (!g_ptt_is_pressed)
|
||||
#endif
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (!g_setting_radio_disabled)
|
||||
#endif
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms
|
||||
{ // start TX'ing
|
||||
|
||||
g_boot_tick_10ms = 0; // cancel the boot-up screen
|
||||
g_ptt_is_pressed = true;
|
||||
g_ptt_was_released = false;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
APP_process_key(KEY_PTT, true, false);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
|
||||
#endif
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (!g_ptt_is_pressed && g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
#else
|
||||
if (!g_ptt_is_pressed)
|
||||
#endif
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms debounce
|
||||
{ // start TX'ing
|
||||
|
||||
g_boot_tick_10ms = 0; // cancel the boot-up screen
|
||||
g_ptt_is_pressed = ptt_pressed;
|
||||
g_ptt_was_released = false;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
APP_process_key(KEY_PTT, true, false);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
g_ptt_debounce = 0;
|
||||
}
|
||||
else
|
||||
g_ptt_debounce = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // PTT released
|
||||
if (g_ptt_is_pressed)
|
||||
|
||||
if (g_ptt_is_pressed && g_current_function == FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms
|
||||
if (++g_ptt_debounce >= 3 || g_serial_config_tick_500ms > 0 || !g_setting_tx_enable) // 30ms debounce
|
||||
{ // stop TX'ing
|
||||
|
||||
g_ptt_is_pressed = false;
|
||||
// g_ptt_is_pressed = false;
|
||||
g_ptt_was_released = true;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
@ -1186,7 +1227,12 @@ void APP_check_keys(void)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
if (g_ptt_is_pressed && !ptt_pressed)
|
||||
g_ptt_is_pressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// *****************
|
||||
@ -1293,17 +1339,19 @@ void APP_check_keys(void)
|
||||
#else
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
#endif
|
||||
|
||||
//g_update_status = true;
|
||||
//g_update_display = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (key == KEY_UP || key == KEY_DOWN)
|
||||
{ // only the up and down keys are repeatable
|
||||
if (++g_key_debounce_repeat >= (key_long_press_10ms + key_repeat_10ms))
|
||||
|
||||
// go much faster if the user is moving up/down freq/channel
|
||||
const uint8_t repeat_10ms = (g_manual_scanning && g_monitor_enabled && g_current_display_screen == DISPLAY_MAIN) ? 1 : key_repeat_10ms;
|
||||
|
||||
if (++g_key_debounce_repeat >= (key_long_press_10ms + repeat_10ms))
|
||||
{ // key repeat
|
||||
g_key_debounce_repeat -= key_repeat_10ms;
|
||||
|
||||
g_key_debounce_repeat = key_long_press_10ms;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("rept key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
|
||||
@ -1317,9 +1365,6 @@ void APP_check_keys(void)
|
||||
#else
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
#endif
|
||||
|
||||
//g_update_status = true;
|
||||
//g_update_display = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1373,7 +1418,7 @@ void APP_cancel_user_input_modes(void)
|
||||
if (g_eeprom.alarm_mode == ALARM_MODE_TONE)
|
||||
{
|
||||
RADIO_tx_eot();
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
@ -1652,7 +1697,7 @@ void APP_process_transmit(void)
|
||||
{
|
||||
g_alarm_state = ALARM_STATE_ALARM;
|
||||
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
BK4819_SetupPowerAmplifier(0, 0);
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, false); // PA off
|
||||
BK4819_Enable_AfDac_DiscMode_TxDsp();
|
||||
|
40
app/main.c
40
app/main.c
@ -43,6 +43,8 @@
|
||||
#include "ui/menu.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
bool g_manual_scanning;
|
||||
|
||||
bool scanning_paused(void)
|
||||
{
|
||||
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) &&
|
||||
@ -862,15 +864,15 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
if (key_pressed && !key_held)
|
||||
{ // key just pressed
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_manual_scanning = false;
|
||||
}
|
||||
|
||||
if (!key_pressed)
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
(Channel <= USER_CHANNEL_LAST || IS_FREQ_CHANNEL(Channel)))
|
||||
{ // key released
|
||||
{ // key released
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && (Channel <= USER_CHANNEL_LAST || IS_FREQ_CHANNEL(Channel)))
|
||||
{
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (key_held && !monitor_was_enabled)
|
||||
{ // re-enable the squelch
|
||||
@ -894,6 +896,8 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
// UART_printf("save chan %u\r\n", g_tx_vfo->channel_save);
|
||||
#endif
|
||||
}
|
||||
|
||||
g_manual_scanning = false;
|
||||
}
|
||||
|
||||
if (key_held || !key_pressed)
|
||||
@ -985,6 +989,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_manual_scanning = true;
|
||||
g_monitor_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// APP_start_listening();
|
||||
@ -1002,18 +1007,6 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
g_tx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (!key_held && key_pressed)
|
||||
monitor_was_enabled = g_monitor_enabled;
|
||||
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_monitor_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// APP_start_listening();
|
||||
}
|
||||
#endif
|
||||
|
||||
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
|
||||
if (Next == 0xFF)
|
||||
return;
|
||||
@ -1021,6 +1014,19 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
if (Channel == Next)
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (!key_held && key_pressed)
|
||||
monitor_was_enabled = g_monitor_enabled;
|
||||
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_manual_scanning = true;
|
||||
g_monitor_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// APP_start_listening();
|
||||
}
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[g_eeprom.tx_vfo] = Next;
|
||||
g_eeprom.screen_channel[g_eeprom.tx_vfo] = Next;
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
extern bool g_manual_scanning;
|
||||
|
||||
void MAIN_process_key(key_code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||
|
||||
#endif
|
||||
|
12
app/menu.c
12
app/menu.c
@ -177,13 +177,13 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
|
||||
case MENU_TX_CDCSS:
|
||||
*pMin = 0;
|
||||
*pMax = 208;
|
||||
//*pMax = (ARRAY_SIZE(DCS_OPTIONS) * 2);
|
||||
//*pMax = (ARRAY_SIZE(DCS_CODE_LIST) * 2);
|
||||
break;
|
||||
|
||||
case MENU_RX_CTCSS:
|
||||
case MENU_TX_CTCSS:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(CTCSS_OPTIONS) - 1;
|
||||
*pMax = ARRAY_SIZE(CTCSS_TONE_LIST) - 1;
|
||||
break;
|
||||
|
||||
case MENU_BANDWIDTH:
|
||||
@ -477,7 +477,7 @@ void MENU_AcceptSetting(void)
|
||||
pConfig->code = Code;
|
||||
pConfig->code_type = CODE_TYPE_NONE;
|
||||
|
||||
BK4819_ExitSubAu();
|
||||
BK4819_disable_sub_audible();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -485,7 +485,7 @@ void MENU_AcceptSetting(void)
|
||||
Code = g_sub_menu_selection - 1;
|
||||
pConfig->code = Code;
|
||||
|
||||
BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]);
|
||||
BK4819_set_CTCSS_freq(CTCSS_TONE_LIST[Code]);
|
||||
}
|
||||
|
||||
g_request_save_channel = 1;
|
||||
@ -910,10 +910,10 @@ void MENU_SelectNextCode(void)
|
||||
|
||||
if (g_menu_cursor == MENU_RX_CDCSS)
|
||||
UpperLimit = 208;
|
||||
//UpperLimit = ARRAY_SIZE(DCS_OPTIONS);
|
||||
//UpperLimit = ARRAY_SIZE(DCS_CODE_LIST);
|
||||
else
|
||||
if (g_menu_cursor == MENU_RX_CTCSS)
|
||||
UpperLimit = ARRAY_SIZE(CTCSS_OPTIONS) - 1;
|
||||
UpperLimit = ARRAY_SIZE(CTCSS_TONE_LIST) - 1;
|
||||
else
|
||||
return;
|
||||
|
||||
|
@ -450,7 +450,7 @@ void SEARCH_process(void)
|
||||
//
|
||||
// RF carrier found, move on to CTCSS/CDCSS search
|
||||
|
||||
BK4819_SetScanFrequency(g_search_frequency);
|
||||
BK4819_set_scan_frequency(g_search_frequency);
|
||||
|
||||
g_search_css_result_type = CODE_TYPE_NONE;
|
||||
g_search_css_result_code = 0xff;
|
||||
@ -576,7 +576,7 @@ void SEARCH_process(void)
|
||||
if (g_search_css_state == SEARCH_CSS_STATE_OFF || g_search_css_state == SEARCH_CSS_STATE_SCANNING)
|
||||
{ // re-start scan
|
||||
|
||||
BK4819_SetScanFrequency(g_search_frequency);
|
||||
BK4819_set_scan_frequency(g_search_frequency);
|
||||
g_search_tick_10ms = search_10ms;
|
||||
}
|
||||
|
||||
@ -630,7 +630,7 @@ void SEARCH_Start(void)
|
||||
|
||||
BK4819_set_rf_filter_path(g_search_frequency);
|
||||
|
||||
BK4819_SetScanFrequency(g_search_frequency);
|
||||
BK4819_set_scan_frequency(g_search_frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user