0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 06:11:24 +03:00

FM radio n DW now friends again

This commit is contained in:
OneOfEleven 2023-11-03 16:41:05 +00:00
parent fba4ece9fd
commit 474317c149
6 changed files with 65 additions and 27 deletions

View File

@ -536,9 +536,12 @@ bool APP_start_listening(void)
(g_eeprom.calib.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
}
FUNCTION_Select(FUNCTION_RECEIVE);
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
BK1080_Init(0, false); // disable the FM radio audio
#endif
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
FUNCTION_Select(FUNCTION_RECEIVE);
#ifdef ENABLE_VOICE
#ifdef MUTE_AUDIO_FOR_VOICE
@ -551,10 +554,7 @@ bool APP_start_listening(void)
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
BK1080_Init(0, false); // disable the FM radio audio
#endif
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
if (g_current_display_screen != DISPLAY_MENU)
GUI_SelectNextDisplay(DISPLAY_MAIN);
@ -866,8 +866,8 @@ static bool APP_toggle_dual_watch_vfo(void)
if (g_dtmf_call_state != DTMF_CALL_STATE_NONE)
return false;
#ifdef ENABLE_FMRADIO
// if (g_fm_radio_mode)
// return false;
if (g_fm_radio_mode)
return false;
#endif
if (g_dual_watch_tick_10ms > 0)
return false;
@ -2213,8 +2213,10 @@ void APP_time_slice_500ms(void)
if (g_current_function != FUNCTION_RECEIVE && g_fm_radio_mode)
{ // switch back to FM radio mode
if (g_current_display_screen != DISPLAY_FM)
{
FM_turn_on();
//GUI_SelectNextDisplay(DISPLAY_FM);
GUI_SelectNextDisplay(DISPLAY_FM);
}
}
}
GUI_SelectNextDisplay(DISPLAY_FM);

View File

@ -895,11 +895,25 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level)
BK4819_WriteRegister(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN));
BK4819_WriteRegister(0x30, 0);
BK4819_WriteRegister(0x30, // all of the following must be enable to get an audio beep ! ???
#if 1
BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_AF_DAC |
BK4819_REG_30_ENABLE_DISC_MODE |
BK4819_REG_30_ENABLE_TX_DSP);
#else
BK4819_WriteRegister(0x30,
BK4819_REG_30_ENABLE_VCO_CALIB |
BK4819_REG_30_ENABLE_UNKNOWN |
// BK4819_REG_30_ENABLE_RX_LINK |
BK4819_REG_30_ENABLE_AF_DAC | //
BK4819_REG_30_ENABLE_DISC_MODE | //
BK4819_REG_30_ENABLE_PLL_VCO |
BK4819_REG_30_ENABLE_PA_GAIN |
// BK4819_REG_30_ENABLE_MIC_ADC |
BK4819_REG_30_ENABLE_TX_DSP | //
// BK4819_REG_30_ENABLE_RX_DSP |
0);
#endif
BK4819_WriteRegister(0x71, scale_freq(frequency));

Binary file not shown.

Binary file not shown.

33
radio.c
View File

@ -646,7 +646,12 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
uint32_t Frequency;
if (!g_monitor_enabled)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
{
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode && g_request_display_screen != DISPLAY_FM)
#endif
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
}
// turn green LED off
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false);
@ -736,16 +741,24 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
(g_eeprom.calib.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
}
#ifdef ENABLE_VOICE
#ifdef MUTE_AUDIO_FOR_VOICE
if (g_voice_write_index == 0)
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
if (!g_monitor_enabled)
{
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode && g_request_display_screen != DISPLAY_FM)
#endif
#else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif
{
#ifdef ENABLE_VOICE
#ifdef MUTE_AUDIO_FOR_VOICE
if (g_voice_write_index == 0)
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif
#else
AUDIO_set_mod_mode(g_rx_vfo->channel.am_mode);
#endif
}
}
interrupt_mask = BK4819_REG_3F_SQUELCH_FOUND | BK4819_REG_3F_SQUELCH_LOST;

View File

@ -125,19 +125,28 @@ void UI_DisplayStatus(const bool test_display)
// DUAL-WATCH indicator
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF || test_display)
{
bool dw_running = true;
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode && g_current_display_screen == DISPLAY_FM)
dw_running = false;
else
#endif
if (g_dual_watch_tick_10ms > dual_watch_delay_toggle_10ms ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_dtmf_call_state != DTMF_CALL_STATE_NONE ||
g_scan_state_dir != SCAN_STATE_DIR_OFF ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
(g_current_function != FUNCTION_FOREGROUND && g_current_function != FUNCTION_POWER_SAVE) ||
g_current_display_screen == DISPLAY_SEARCH)
{
memcpy(line + x, BITMAP_TDR_HOLDING, sizeof(BITMAP_TDR_HOLDING));
dw_running = false;
}
else
{
if (dw_running)
memcpy(line + x, BITMAP_TDR_RUNNING, sizeof(BITMAP_TDR_RUNNING));
}
else
memcpy(line + x, BITMAP_TDR_HOLDING, sizeof(BITMAP_TDR_HOLDING));
x += sizeof(BITMAP_TDR_RUNNING) + 1;
}