0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-18 07:51:19 +03:00
This commit is contained in:
OneOfEleven 2023-11-19 06:59:38 +00:00
parent 01d33895c0
commit 4ff7f54c81
12 changed files with 118 additions and 103 deletions

View File

@ -27,7 +27,7 @@ ENABLE_NOAA := 0
ENABLE_VOICE := 0
ENABLE_MUTE_RADIO_FOR_VOICE := 0
# Tx on Voice 1.0 kB
ENABLE_VOX := 0
ENABLE_VOX := 1
ENABLE_VOX_MORE_SENSITIVE := 1
ENABLE_REDUCE_LOW_MID_TX_POWER := 1
# Tx Alarm 600 B
@ -82,7 +82,7 @@ ENABLE_TX_AUDIO_BAR := 0
ENABLE_SIDE_BUTT_MENU := 0
# Key Lock 400 B
ENABLE_KEYLOCK := 1
ENABLE_PANADAPTER := 1
ENABLE_PANADAPTER := 0
#ENABLE_SINGLE_VFO_CHAN := 0
#############################################################

View File

@ -449,6 +449,12 @@ void AM_fix_10ms(const int vfo)
#endif
}
void AM_fix_set_front_end_gains(const int vfo)
{
const unsigned int index = gain_table_index_prev[vfo];
BK4819_write_reg(0x13, gain_table[index].reg_val);
}
#ifdef ENABLE_AM_FIX_SHOW_DATA
void AM_fix_print_data(const int vfo, char *s)

View File

@ -26,6 +26,7 @@ extern int16_t rssi_gain_diff[2];
void AM_fix_init(void);
void AM_fix_reset(const int vfo);
void AM_fix_10ms(const int vfo);
void AM_fix_set_front_end_gains(const int vfo);
#ifdef ENABLE_AM_FIX_SHOW_DATA
void AM_fix_print_data(const int vfo, char *s);
#endif

View File

@ -85,7 +85,7 @@ static void APP_update_rssi(const int vfo, const bool force)
#ifdef ENABLE_AM_FIX
// add RF gain adjust compensation
#ifdef ENABLE_PANADAPTER
if (!g_pan_enabled || g_panadapter_vfo_mode > 0)
if (!PAN_scanning())
#endif
if (g_current_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
rssi -= rssi_gain_diff[vfo];
@ -105,6 +105,11 @@ static void APP_update_rssi(const int vfo, const bool force)
static void APP_check_for_new_receive(void)
{
#ifdef ENABLE_PANADAPTER
if (PAN_scanning())
return;
#endif
if (!g_squelch_open && !g_monitor_enabled)
return;
@ -179,6 +184,14 @@ static void APP_process_new_receive(void)
{
bool flag;
#ifdef ENABLE_PANADAPTER
if (PAN_scanning())
{
BK4819_set_AFC(0);
return;
}
#endif
if (!g_squelch_open)
BK4819_set_AFC(0);
@ -273,6 +286,11 @@ typedef enum end_of_rx_mode_e end_of_rx_mode_t;
static void APP_process_rx(void)
{
#ifdef ENABLE_PANADAPTER
if (PAN_scanning())
return;
#endif
end_of_rx_mode_t Mode = END_OF_RX_MODE_NONE;
// APP_update_rssi(g_rx_vfo_num);
@ -2228,6 +2246,10 @@ void APP_time_slice_500ms(void)
g_reduced_service = true;
#ifdef ENABLE_PANADAPTER
PAN_process_10ms(); // disable the panadapter
#endif
FUNCTION_Select(FUNCTION_POWER_SAVE);
ST7565_HardwareReset();
@ -2426,10 +2448,10 @@ void APP_time_slice_10ms(void)
#endif
#ifdef ENABLE_AM_FIX
if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
#ifdef ENABLE_PANADAPTER
if (!g_eeprom.config.setting.panadapter || g_panadapter_vfo_mode > 0)
#endif
#ifdef ENABLE_PANADAPTER
if (!PAN_scanning())
#endif
if (g_rx_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
AM_fix_10ms(g_rx_vfo_num);
#endif
@ -2456,17 +2478,19 @@ void APP_time_slice_10ms(void)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
#endif
// 1of11
// if (g_update_rssi)
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
if (!g_flag_save_channel)
#ifdef ENABLE_PANADAPTER
if (!g_eeprom.config.setting.panadapter || g_panadapter_vfo_mode > 0)
#endif
APP_update_rssi(g_rx_vfo_num, false);
#ifdef ENABLE_PANADAPTER
if (!PAN_scanning())
#endif
{
// 1of11
// if (g_update_rssi)
if (g_current_function != FUNCTION_POWER_SAVE && g_current_function != FUNCTION_TRANSMIT)
if (!g_flag_save_channel)
APP_update_rssi(g_rx_vfo_num, false);
if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode)
APP_process_radio_interrupts();
if (g_current_function != FUNCTION_POWER_SAVE || !g_rx_idle_mode)
APP_process_radio_interrupts();
}
APP_process_functions();
@ -2528,8 +2552,7 @@ void APP_time_slice_10ms(void)
#endif
#ifdef ENABLE_PANADAPTER
if (g_eeprom.config.setting.panadapter)
PAN_process_10ms();
PAN_process_10ms();
#endif
APP_process_power_save();

View File

@ -679,7 +679,6 @@ void MENU_AcceptSetting(void)
#ifdef ENABLE_PANADAPTER
case MENU_PANADAPTER:
g_eeprom.config.setting.panadapter = g_sub_menu_selection;
PAN_enable((g_eeprom.config.setting.panadapter != 0) ? true : false);
break;
#endif

Binary file not shown.

Binary file not shown.

7
main.c
View File

@ -44,9 +44,6 @@
#include "mdc1200.h"
#endif
#include "misc.h"
#ifdef ENABLE_PANADAPTER
#include "panadapter.h"
#endif
#include "radio.h"
#include "settings.h"
#include "ui/helper.h"
@ -243,10 +240,6 @@ void Main(void)
AM_fix_init();
#endif
#ifdef ENABLE_PANADAPTER
PAN_enable((g_eeprom.config.setting.panadapter != 0) ? true : false);
#endif
BK4819_set_mic_gain(g_mic_sensitivity_tuning);
RADIO_configure_channel(0, VFO_CONFIGURE_RELOAD);

View File

@ -1,4 +1,7 @@
#ifdef ENABLE_AM_FIX
#include "am_fix.h"
#endif
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h"
#endif
@ -14,13 +17,15 @@
#include "ui/main.h"
#include "ui/ui.h"
bool g_pan_enabled = false;
// a list of frequencies to ignore/skip when scanning
bool g_pan_enabled;
int g_panadapter_vfo_mode; // > 0 if we're currently sampling the VFO
uint8_t g_panadapter_rssi[PANADAPTER_BINS + 1 + PANADAPTER_BINS];
int g_panadapter_rssi_index;
int g_panadapter_vfo_mode; // > 0 if we're currently sampling the VFO
bool PAN_scanning(void)
{
return (g_eeprom.config.setting.panadapter && g_pan_enabled && g_panadapter_vfo_mode <= 0) ? true : false;
}
void PAN_set_freq(void)
{ // set the frequency
@ -28,7 +33,7 @@ void PAN_set_freq(void)
const uint32_t step_size = g_tx_vfo->step_freq;
uint32_t freq = g_tx_vfo->p_rx->frequency;
if (g_panadapter_vfo_mode <= 0)
if (g_pan_enabled && g_panadapter_vfo_mode <= 0)
{ // panadapter mode .. add the bin offset
if (g_panadapter_rssi_index < PANADAPTER_BINS)
freq -= step_size * (PANADAPTER_BINS - g_panadapter_rssi_index);
@ -41,72 +46,58 @@ void PAN_set_freq(void)
//BK4819_set_rf_filter_path(freq); // set the proper LNA/PA filter path
// default front end gains
if (g_panadapter_vfo_mode <= 0)
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
}
void PAN_clear(void)
{
g_panadapter_rssi_index = 0;
memset(g_panadapter_rssi, 0, sizeof(g_panadapter_rssi));
g_panadapter_vfo_mode = 1;
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
// UART_printf("%u\r\n", g_panadapter_rssi_index);
#ifdef ENABLE_AM_FIX
if (g_panadapter_vfo_mode <= 0 || g_tx_vfo->channel.mod_mode == MOD_MODE_FM)
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
else
AM_fix_set_front_end_gains(g_eeprom.config.setting.tx_vfo_num);
#endif
}
void PAN_enable(const bool enable)
void PAN_process_10ms(void)
{
if (enable && g_eeprom.config.setting.panadapter)
{
if (!g_pan_enabled)
{
PAN_clear();
g_panadapter_vfo_mode = 0;
PAN_set_freq();
g_pan_enabled = true;
//g_update_display = true;
UI_DisplayMain_pan(true);
}
}
else
if (!g_eeprom.config.setting.panadapter ||
#ifdef ENABLE_FMRADIO
g_fm_radio_mode ||
#endif
g_reduced_service ||
g_monitor_enabled ||
g_current_function == FUNCTION_TRANSMIT ||
g_current_function == FUNCTION_POWER_SAVE ||
g_current_function == FUNCTION_NEW_RECEIVE ||
g_current_function == FUNCTION_RECEIVE ||
g_current_display_screen == DISPLAY_SEARCH ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_scan_state_dir != SCAN_STATE_DIR_OFF)
{
if (g_pan_enabled)
{
PAN_clear();
{ // disable the panadapter
g_panadapter_vfo_mode = 1;
g_pan_enabled = false;
PAN_set_freq();
g_pan_enabled = false;
g_update_display = true;
g_update_display = true;
//UI_DisplayMain_pan(true);
}
return;
}
}
bool PAN_process_10ms(void)
{
if (!g_pan_enabled)
return false;
{ // enable the panadapter
if (g_current_function == FUNCTION_TRANSMIT ||
g_current_function == FUNCTION_POWER_SAVE ||
g_current_function == FUNCTION_NEW_RECEIVE ||
g_current_function == FUNCTION_RECEIVE)
return false;
g_panadapter_vfo_mode = 0;
g_panadapter_rssi_index = 0;
// memset(g_panadapter_rssi, 0, sizeof(g_panadapter_rssi));
g_pan_enabled = true;
PAN_set_freq();
if (g_current_display_screen == DISPLAY_SEARCH ||
g_css_scan_mode != CSS_SCAN_MODE_OFF ||
g_scan_state_dir != SCAN_STATE_DIR_OFF)
return false;
g_update_display = true;
//UI_DisplayMain_pan(true);
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
return false;
#endif
if (g_squelch_open || g_monitor_enabled)
return false;
return;
}
if (g_panadapter_vfo_mode <= 0)
{ // save the current RSSI value
@ -115,25 +106,27 @@ bool PAN_process_10ms(void)
}
if (g_panadapter_vfo_mode <= 0)
{
{ // scanning
if (++g_panadapter_rssi_index >= (int)ARRAY_SIZE(g_panadapter_rssi))
g_panadapter_rssi_index = 0;
// switch back to the VFO frequency once every 16 frequency steps .. if in FM mode
if (g_tx_vfo->channel.mod_mode == MOD_MODE_FM)
// switch back to the VFO frequency once every 16 frequency steps .. if in FM mode
g_panadapter_vfo_mode = ((g_panadapter_rssi_index & 15u) == 0) ? 1 : 0;
else
// switch back to the VFO frequency once each scan cycle if not in FM mode
g_panadapter_vfo_mode = (g_panadapter_rssi_index == 0) ? 1 : 0;
}
else
if (++g_panadapter_vfo_mode >= 8)
{
g_panadapter_vfo_mode = 0;
{ // checking the VFO frequency for a signal .. we do this this periodically
if (++g_panadapter_vfo_mode >= 9) // monitor the VFO frequency for 90ms before continuing our scan
g_panadapter_vfo_mode = 0;
}
PAN_set_freq();
// the last bin value .. draw the panadapter once each scan cycle
if (g_panadapter_rssi_index == 0 && g_panadapter_vfo_mode <= 1)
UI_DisplayMain_pan(true); // the last bin value - show the panadapter
// g_update_display = true;
return (g_panadapter_vfo_mode <= 0) ? true : false;
UI_DisplayMain_pan(true);
//g_update_display = true;
}

View File

@ -26,12 +26,11 @@
#define PANADAPTER_BINS ((LCD_WIDTH / 2) - 1)
extern bool g_pan_enabled;
extern uint8_t g_panadapter_rssi[PANADAPTER_BINS + 1 + PANADAPTER_BINS];
extern int g_panadapter_vfo_mode;
extern uint8_t g_panadapter_rssi[PANADAPTER_BINS + 1 + PANADAPTER_BINS];
void PAN_clear(void);
void PAN_enable(const bool enable);
bool PAN_process_10ms(void);
bool PAN_scanning(void);
void PAN_process_10ms(void);
#endif

View File

@ -360,7 +360,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
if (p_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
{
#ifdef ENABLE_PANADAPTER
if (!g_pan_enabled || g_panadapter_vfo_mode > 0)
if (!PAN_scanning())
{
AM_fix_10ms(VFO);
}
@ -382,7 +382,7 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
if (p_vfo->mod_mode != MOD_MODE_FM)
{
#ifdef ENABLE_PANADAPTER
if (!g_pan_enabled || g_panadapter_vfo_mode > 0)
if (!PAN_scanning())
{
BK4819_EnableAGC();
}

View File

@ -417,9 +417,9 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
uint8_t span_rssi;
unsigned int i;
if (!g_eeprom.config.setting.panadapter)
if (!g_eeprom.config.setting.panadapter || !g_pan_enabled || g_panadapter_vfo_mode > 0)
return;
if (!g_pan_enabled || single_vfo < 0 || g_current_display_screen != DISPLAY_MAIN)
if (single_vfo < 0 || g_current_display_screen != DISPLAY_MAIN)
return;
if (g_squelch_open || g_monitor_enabled)
return;
@ -474,7 +474,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
}
// center marker (the VFO frequency)
base_line[(ARRAY_SIZE(g_panadapter_rssi) / 2) - (LCD_WIDTH * 2)] ^= 0xAA;
base_line[(ARRAY_SIZE(g_panadapter_rssi) / 2) - (LCD_WIDTH * 2)] = 0xAA;
// top horizontal line
for (i = 0; i < ARRAY_SIZE(g_panadapter_rssi); i += 2)
@ -509,8 +509,9 @@ void UI_DisplayMain(void)
#ifdef ENABLE_PANADAPTER
if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF && g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF)
if (!g_squelch_open && !g_monitor_enabled && g_eeprom.config.setting.panadapter)
single_vfo = g_eeprom.config.setting.tx_vfo_num;
if (g_eeprom.config.setting.panadapter && g_pan_enabled)
if (!g_squelch_open && !g_monitor_enabled)
single_vfo = g_eeprom.config.setting.tx_vfo_num;
#endif
// clear the screen