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

Fix scanning chan/freq button functions

This commit is contained in:
OneOfEleven 2023-10-17 17:25:14 +01:00
parent 0908ff9bc0
commit 4cdd17888c
8 changed files with 109 additions and 81 deletions

View File

@ -195,7 +195,7 @@ static void APP_process_incoming_rx(void)
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
{ // not code scanning
#ifdef ENABLE_KILL_REVIVE
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
#else
@ -470,7 +470,6 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{ // we're RF scanning
switch (g_eeprom.scan_resume_mode)
{
case SCAN_RESUME_TO:
@ -486,10 +485,6 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
g_scan_pause_10ms = 0;
break;
}
// g_scan_restore_channel = 0xff;
// g_scan_restore_frequency = 0;
// g_scan_keep_frequency = true;
}
#ifdef ENABLE_NOAA
@ -517,7 +512,8 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
g_update_status = true;
}
#ifdef ENABLE_AM_FIX
{ // RF RX front end gain
// original setting
@ -526,17 +522,18 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix)
uint16_t mixer = orig_mixer;
uint16_t pga = orig_pga;
#ifdef ENABLE_AM_FIX
if (g_rx_vfo->am_mode && g_setting_am_fix)
{ // AM RX mode
if (reset_am_fix)
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency .. or do we ???
AM_fix_10ms(chan);
}
else
#endif
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
if (g_rx_vfo->am_mode && g_setting_am_fix)
{ // AM RX mode
if (reset_am_fix)
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency .. or do we ???
AM_fix_10ms(chan);
}
else
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
}
#else
(void)reset_am_fix;
#endif
// AF gain - original QS values
BK4819_WriteRegister(BK4819_REG_48,
@ -610,27 +607,28 @@ void APP_stop_scan(void)
// 1of11
if (g_scan_pause_mode ||
g_scan_pause_10ms > (200 / 10) ||
g_current_function == FUNCTION_RECEIVE ||
g_current_function == FUNCTION_MONITOR ||
g_current_function == FUNCTION_INCOMING)
{ // stay where we are
g_scan_pause_mode = false;
g_scan_restore_frequency = 0xffffffff;
g_scan_restore_channel = 0xff;
g_scan_restore_frequency = 0xffffffff;
}
if (g_scan_restore_channel != 0xff ||
(g_scan_restore_frequency > 0 && g_scan_restore_frequency != 0xffffffff))
{ // revert to where we were when starting the scan
if (g_scan_next_channel <= USER_CHANNEL_LAST)
{ // we were channel hopping
if (g_scan_restore_channel != 0xff)
{
g_eeprom.user_channel[g_eeprom.rx_vfo] = g_scan_restore_channel;
g_eeprom.screen_channel[g_eeprom.rx_vfo] = g_scan_restore_channel;
RADIO_configure_channel(g_eeprom.rx_vfo, VFO_CONFIGURE_RELOAD);
RADIO_setup_registers(true);
}
@ -649,18 +647,19 @@ void APP_stop_scan(void)
g_update_display = true;
}
else
{
{ // stay where we are
if (g_rx_vfo->channel_save > USER_CHANNEL_LAST)
{
{ // frequency mode
RADIO_ApplyOffset(g_rx_vfo);
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
SETTINGS_SaveChannel(g_rx_vfo->channel_save, g_eeprom.rx_vfo, g_rx_vfo, 1);
return;
}
SETTINGS_SaveVfoIndices();
}
g_update_status = true;
}
@ -682,7 +681,7 @@ static void APP_next_freq(void)
RADIO_setup_registers(true);
#ifdef ENABLE_FASTER_CHANNEL_SCAN
g_scan_pause_10ms = 8; // 80ms
g_scan_pause_10ms = 10; // 100ms
#else
g_scan_pause_10ms = scan_pause_freq_10ms;
#endif
@ -699,7 +698,6 @@ static void APP_next_freq(void)
#endif
}
// g_scan_keep_frequency = false;
g_update_display = true;
}
@ -799,8 +797,6 @@ static void APP_next_channel(void)
g_scan_pause_10ms = scan_pause_chan_10ms;
#endif
// g_scan_keep_frequency = false;
if (enabled)
if (++g_scan_current_scan_list >= SCAN_NEXT_NUM)
g_scan_current_scan_list = SCAN_NEXT_CHAN_SCANLIST1; // back round we go
@ -819,7 +815,7 @@ static void APP_toggle_dual_watch_vfo(void)
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("dual watch\r\n");
#endif
#ifdef ENABLE_NOAA
if (g_is_noaa_mode)
{
@ -1148,7 +1144,7 @@ void APP_process(void)
if (g_css_scan_mode == CSS_SCAN_MODE_SCANNING && g_scan_pause_10ms == 0)
MENU_SelectNextCode();
}
#ifdef ENABLE_NOAA
#ifdef ENABLE_VOICE
if (g_voice_write_index == 0)
@ -1357,14 +1353,14 @@ void APP_check_keys(void)
{
if (++g_ptt_debounce >= 3) // 30ms
{ // start TX'ing
g_boot_counter_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
@ -1602,12 +1598,12 @@ void APP_time_slice_10ms(void)
#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)
@ -1770,12 +1766,12 @@ void APP_time_slice_10ms(void)
if (g_search_freq_css_timer_10ms >= scan_freq_css_timeout_10ms)
{ // FREQ/CTCSS/CDCSS search timeout
if (!g_search_single_frequency)
{ // FREQ search timeout
#ifdef ENABLE_FREQ_SEARCH_TIMEOUT
BK4819_DisableFrequencyScan();
g_search_css_state = SEARCH_CSS_STATE_FREQ_FAILED;
AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP);
@ -1788,7 +1784,7 @@ void APP_time_slice_10ms(void)
{ // CTCSS/CDCSS search timeout
#ifdef ENABLE_CODE_SEARCH_TIMEOUT
BK4819_DisableFrequencyScan();
g_search_css_state = SEARCH_CSS_STATE_FREQ_FAILED;
AUDIO_PlayBeep(BEEP_880HZ_60MS_TRIPLE_BEEP);
@ -2066,7 +2062,7 @@ void APP_time_slice_500ms(void)
if (g_eeprom.backlight < (ARRAY_SIZE(g_sub_menu_backlight) - 1))
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn backlight off
}
if (g_reduced_service)
{
BOARD_ADC_GetBatteryInfo(&g_usb_current_voltage, &g_usb_current);
@ -2376,8 +2372,6 @@ void APP_channel_next(const bool flag, const scan_state_dir_t scan_direction)
g_scan_pause_10ms = scan_pause_css_10ms;
g_scan_pause_mode = false;
// g_scan_keep_frequency = false;
g_rx_reception_mode = RX_MODE_NONE;
}
@ -2392,17 +2386,21 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const
// reset the state so as to remove it from the screen
if (Key != KEY_INVALID && Key != KEY_PTT)
RADIO_Setg_vfo_state(VFO_STATE_NORMAL);
/*
#if 0
// remember the current backlight state (on / off)
const bool backlight_was_on = GPIO_CheckBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
if (Key == KEY_EXIT && !backlight_was_on && g_eeprom.backlight > 0)
{ // just turn the light on for now so the user can see what's what
backlight_turn_on(0);
{ // just turn the back light on for now so the user can see what's what
if (!key_pressed && !key_held)
{ // key has been released
backlight_turn_on(0);
}
g_beep_to_play = BEEP_NONE;
return;
}
*/
#endif
// turn the backlight on
if (key_pressed)
if (Key != KEY_PTT)
@ -2788,7 +2786,7 @@ Skip:
{
RADIO_configure_channel(g_eeprom.tx_vfo, g_vfo_configure_mode);
}
if (g_request_display_screen == DISPLAY_INVALID)
g_request_display_screen = DISPLAY_MAIN;

View File

@ -57,25 +57,24 @@ static void MAIN_stop_scan(void)
void toggle_chan_scanlist(void)
{ // toggle the selected channels scanlist setting
if (g_screen_to_display != DISPLAY_MAIN || !IS_USER_CHANNEL(g_tx_vfo->channel_save))
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (g_current_function != FUNCTION_FOREGROUND &&
g_current_function != FUNCTION_INCOMING &&
g_current_function != FUNCTION_MONITOR &&
g_current_function != FUNCTION_RECEIVE)
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (g_scan_pause_10ms > 0 && !g_scan_pause_mode)
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
if (g_screen_to_display != DISPLAY_MAIN ||
!IS_USER_CHANNEL(g_tx_vfo->channel_save) ||
g_current_function == FUNCTION_TRANSMIT ||
g_current_function == FUNCTION_PANADAPTER)
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
if (g_scan_pause_10ms > 0 &&
g_scan_pause_10ms <= (200 / 10) &&
!g_scan_pause_mode)
{
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
}
if (g_tx_vfo->scanlist_1_participation)

View File

@ -49,8 +49,8 @@ void BK4819_Init(void)
BK4819_WriteRegister(BK4819_REG_37, 0x1D0F);
BK4819_WriteRegister(BK4819_REG_36, 0x0022);
BK4819_SetAGC(0);
// BK4819_SetAGC(1);
// BK4819_SetAGC(0);
BK4819_SetAGC(1); // ???
BK4819_WriteRegister(BK4819_REG_19, 0x1041); // 0001 0000 0100 0001 <15> MIC AGC 1 = disable 0 = enable
@ -111,6 +111,33 @@ void BK4819_Init(void)
BK4819_WriteRegister(BK4819_REG_33, 0x9000);
BK4819_WriteRegister(BK4819_REG_3F, 0);
#if 0
// rt-890
// BK4819_WriteRegister(0x37, 0x1D0F);
// DisableAGC(0);
BK4819_WriteRegister(0x13, 0x03BE);
BK4819_WriteRegister(0x12, 0x037B);
BK4819_WriteRegister(0x11, 0x027B);
BK4819_WriteRegister(0x10, 0x007A);
BK4819_WriteRegister(0x14, 0x0019);
BK4819_WriteRegister(0x49, 0x2A38);
BK4819_WriteRegister(0x7B, 0x8420);
BK4819_WriteRegister(0x33, 0x1F00);
BK4819_WriteRegister(0x35, 0x0000);
BK4819_WriteRegister(0x1E, 0x4C58);
BK4819_WriteRegister(0x1F, 0xA656);
// BK4819_WriteRegister(0x3E, gCalibration.BandSelectionThreshold);
BK4819_WriteRegister(0x3F, 0x0000);
BK4819_WriteRegister(0x2A, 0x4F18);
BK4819_WriteRegister(0x53, 0xE678);
BK4819_WriteRegister(0x2C, 0x5705);
BK4819_WriteRegister(0x4B, 0x7102);
BK4819_WriteRegister(0x77, 0x88EF);
BK4819_WriteRegister(0x26, 0x13A0);
#endif
}
static uint16_t BK4819_ReadU16(void)
@ -778,19 +805,19 @@ void BK4819_SetupSquelch(
// 0 ~ 255
//
BK4819_WriteRegister(BK4819_REG_4E, // 01 101 11 1 00000000
#ifndef ENABLE_FASTER_CHANNEL_SCAN
// #ifndef ENABLE_FASTER_CHANNEL_SCAN
// original (*)
(1u << 14) | // 1 ???
(3u << 11) | // *5 squelch = open delay .. 0 ~ 7
(2u << 9) | // *3 squelch = close delay .. 0 ~ 3
squelch_open_glitch_thresh); // 0 ~ 255
#else
(1u << 14) | // 1 ???
(5u << 11) | // 5 squelch = open delay .. 0 ~ 7
(6u << 9) | // *3 squelch = close delay .. 0 ~ 3
squelch_open_glitch_thresh); // 0 ~ 255
// #else
// faster (but twitchier)
(1u << 14) | // 1 ???
(2u << 11) | // *5 squelch = open delay .. 0 ~ 7
(1u << 9) | // *3 squelch = close delay .. 0 ~ 3
squelch_open_glitch_thresh); // 0 ~ 255
#endif
// (1u << 14) | // 1 ???
// (2u << 11) | // *5 squelch = open delay .. 0 ~ 7
// (1u << 9) | // *3 squelch = close delay .. 0 ~ 3
// squelch_open_glitch_thresh); // 0 ~ 255
// #endif
// REG_4F
//

Binary file not shown.

Binary file not shown.

1
misc.c
View File

@ -221,7 +221,6 @@ uint8_t g_scan_next_channel;
scan_next_chan_t g_scan_current_scan_list;
uint8_t g_scan_restore_channel;
uint32_t g_scan_restore_frequency;
//bool g_scan_keep_frequency;
bool g_scan_pause_mode;
volatile uint16_t g_scan_pause_10ms;
scan_state_dir_t g_scan_state_dir;

1
misc.h
View File

@ -301,7 +301,6 @@ extern uint8_t g_scan_next_channel; //
extern scan_next_chan_t g_scan_current_scan_list; //
extern uint8_t g_scan_restore_channel; // the channel we were on before starting the RF scan
extern uint32_t g_scan_restore_frequency; // the frequency we were on before starting the RF scan
//extern bool g_scan_keep_frequency;
extern bool g_scan_pause_mode; // set if we're paused on a channel or frequency ?
extern volatile uint16_t g_scan_pause_10ms; // ticks till we move to next channel/frequency
extern scan_state_dir_t g_scan_state_dir; // the direction we're scanning in

View File

@ -907,8 +907,13 @@ void RADIO_enableTX(const bool fsk_tx)
#pragma GCC diagnostic pop
BK4819_set_rf_frequency(g_current_vfo->p_tx->frequency, false);
// if DTMF is enabled when TX'ing, it changes the TX audio filtering ! .. 1of11
// so MAKE SURE that DTMF is disabled - until needed
BK4819_DisableDTMF();
BK4819_SetCompander((!fsk_tx && g_rx_vfo->am_mode == 0 && (g_rx_vfo->compander == 1 || g_rx_vfo->compander >= 3)) ? g_rx_vfo->compander : 0);
BK4819_set_rf_frequency(g_current_vfo->p_tx->frequency, false);
BK4819_PrepareTransmit();
BK4819_PickRXFilterPathBasedOnFrequency(g_current_vfo->p_tx->frequency);
BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1_UNKNOWN, true); // ???
@ -916,6 +921,7 @@ void RADIO_enableTX(const bool fsk_tx)
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
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, true); // turn the RED LED on
if (fsk_tx)