0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-05-18 16:01:18 +03:00

panadapter update

This commit is contained in:
OneOfEleven 2023-11-20 13:20:12 +00:00
parent 2e4cd3d135
commit 88405681fd
10 changed files with 110 additions and 116 deletions

View File

@ -292,7 +292,6 @@ void AM_fix_10ms(const int vfo)
switch (g_current_function) switch (g_current_function)
{ {
case FUNCTION_TRANSMIT: case FUNCTION_TRANSMIT:
case FUNCTION_PANADAPTER:
case FUNCTION_POWER_SAVE: case FUNCTION_POWER_SAVE:
#ifdef ENABLE_AM_FIX_SHOW_DATA #ifdef ENABLE_AM_FIX_SHOW_DATA
display_update_tick = display_update_rate; // queue up a display update as soon as we switch to RX mode display_update_tick = display_update_rate; // queue up a display update as soon as we switch to RX mode

View File

@ -1813,9 +1813,6 @@ void APP_process_functions(void)
APP_check_for_new_receive(); APP_check_for_new_receive();
break; break;
case FUNCTION_PANADAPTER:
break;
default: default:
break; break;
} }

View File

@ -78,9 +78,7 @@ void toggle_chan_scanlist(void)
return; return;
} }
if (g_current_display_screen != DISPLAY_MAIN || if (g_current_display_screen != DISPLAY_MAIN || g_current_function == FUNCTION_TRANSMIT)
g_current_function == FUNCTION_TRANSMIT ||
g_current_function == FUNCTION_PANADAPTER)
{ {
g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
@ -1110,7 +1108,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t directio
#endif #endif
#ifdef ENABLE_PANADAPTER #ifdef ENABLE_PANADAPTER
g_panadapter_vfo_mode = 20; // 200ms g_panadapter_vfo_tick = 20; // 200ms
#endif #endif
BK4819_set_rf_frequency(freq, true); // set the VCO/PLL BK4819_set_rf_frequency(freq, true); // set the VCO/PLL

Binary file not shown.

Binary file not shown.

View File

@ -294,13 +294,6 @@ void FUNCTION_Select(function_type_t Function)
BK4819_set_scrambler(g_current_vfo->channel.scrambler); BK4819_set_scrambler(g_current_vfo->channel.scrambler);
break; break;
case FUNCTION_PANADAPTER:
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_SendText("func panadpter\r\n");
#endif
break;
} }
g_power_save_pause_tick_10ms = power_save_pause_10ms; g_power_save_pause_tick_10ms = power_save_pause_10ms;

View File

@ -26,8 +26,7 @@ enum function_type_e
// FUNCTION_MONITOR, // receiving with squelch forced open // FUNCTION_MONITOR, // receiving with squelch forced open
FUNCTION_NEW_RECEIVE, // signal just received FUNCTION_NEW_RECEIVE, // signal just received
FUNCTION_RECEIVE, // receive mode FUNCTION_RECEIVE, // receive mode
FUNCTION_POWER_SAVE, // sleeping FUNCTION_POWER_SAVE // sleeping
FUNCTION_PANADAPTER // bandscope mode (panadpter/spectrum) .. not yet implemented
}; };
typedef enum function_type_e function_type_t; typedef enum function_type_e function_type_t;

View File

@ -23,18 +23,19 @@ bool g_panadapter_enabled;
#ifdef ENABLE_PANADAPTER_PEAK_FREQ #ifdef ENABLE_PANADAPTER_PEAK_FREQ
uint32_t g_panadapter_peak_freq; uint32_t g_panadapter_peak_freq;
#endif #endif
int g_panadapter_vfo_mode; // > 0 if we're currently sampling the VFO int g_panadapter_vfo_tick; // >0 if we're currently monitoring the VFO/center frequency
uint8_t g_panadapter_max_rssi; unsigned int g_panadapter_cycles; //
uint8_t g_panadapter_min_rssi; uint8_t g_panadapter_max_rssi; //
uint8_t g_panadapter_rssi[PANADAPTER_BINS + 1 + PANADAPTER_BINS]; uint8_t g_panadapter_min_rssi; //
int panadapter_rssi_index; uint8_t g_panadapter_rssi[PANADAPTER_BINS + 1 + PANADAPTER_BINS]; // holds the RSSI samples
int panadapter_delay; int panadapter_rssi_index; //
int panadapter_delay; // used to give the VCO/PLL/RSSI time to settle
const uint8_t panadapter_min_rssi = (-147 + 160) * 2; // min of -147dBm (S0) const uint8_t panadapter_min_rssi = (-147 + 160) * 2; // -147dBm (S0) min RSSI value
bool PAN_scanning(void) bool PAN_scanning(void)
{ {
return (g_eeprom.config.setting.panadapter && g_panadapter_enabled && g_panadapter_vfo_mode <= 0) ? true : false; return (g_eeprom.config.setting.panadapter && g_panadapter_enabled && g_panadapter_vfo_tick <= 0) ? true : false;
} }
void PAN_update_min_max(void) void PAN_update_min_max(void)
@ -58,7 +59,7 @@ void PAN_update_min_max(void)
#ifdef ENABLE_PANADAPTER_PEAK_FREQ #ifdef ENABLE_PANADAPTER_PEAK_FREQ
void PAN_find_peak(void) void PAN_find_peak(void)
{ // find the peak freq { // find the peak frequency
const int32_t center_freq = g_tx_vfo->p_rx->frequency; const int32_t center_freq = g_tx_vfo->p_rx->frequency;
int32_t step_size = g_tx_vfo->step_freq; int32_t step_size = g_tx_vfo->step_freq;
@ -92,24 +93,27 @@ void PAN_update_min_max(void)
#endif #endif
void PAN_set_freq(void) void PAN_set_freq(void)
{ // set the frequency { // set the VCO/PLL frequency
int32_t freq = g_tx_vfo->p_rx->frequency; int32_t freq = g_tx_vfo->p_rx->frequency;
// if not paused on the VFO/center freq, add the panadapter bin offset frequency
if (g_panadapter_enabled && g_panadapter_vfo_tick <= 0 && panadapter_rssi_index >= 0)
{
int32_t step_size = g_tx_vfo->step_freq; int32_t step_size = g_tx_vfo->step_freq;
// limit the step size // limit the step size
step_size = (step_size < PANADAPTER_MIN_STEP) ? PANADAPTER_MIN_STEP : (step_size > PANADAPTER_MAX_STEP) ? PANADAPTER_MAX_STEP : step_size; step_size = (step_size < PANADAPTER_MIN_STEP) ? PANADAPTER_MIN_STEP : (step_size > PANADAPTER_MAX_STEP) ? PANADAPTER_MAX_STEP : step_size;
// if not paused on the VFO/center freq, add the bin offset (scanning)
if (g_panadapter_enabled && g_panadapter_vfo_mode <= 0 && panadapter_rssi_index >= 0)
freq += step_size * (panadapter_rssi_index - PANADAPTER_BINS); freq += step_size * (panadapter_rssi_index - PANADAPTER_BINS);
}
BK4819_set_rf_frequency(freq, true); // set the VCO/PLL BK4819_set_rf_frequency(freq, true); // set the VCO/PLL
//BK4819_set_rf_filter_path(freq); // set the proper LNA/PA filter path .. no need, we're not moving far //BK4819_set_rf_filter_path(freq); // set the proper LNA/PA filter path .. don't bother, we're not moving far from the VFO/center frequency
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
// set front end gains // set front end gains
if (g_panadapter_vfo_mode <= 0 || g_tx_vfo->channel.mod_mode == MOD_MODE_FM) if (g_panadapter_vfo_tick <= 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)); BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
else else
AM_fix_set_front_end_gains(g_eeprom.config.setting.tx_vfo_num); AM_fix_set_front_end_gains(g_eeprom.config.setting.tx_vfo_num);
@ -135,14 +139,8 @@ void PAN_process_10ms(void)
{ {
if (g_panadapter_enabled) if (g_panadapter_enabled)
{ // disable the panadapter { // disable the panadapter
#ifdef ENABLE_PANADAPTER_PEAK_FREQ
g_panadapter_peak_freq = 0;
#endif
g_panadapter_vfo_mode = 1;
g_panadapter_enabled = false; g_panadapter_enabled = false;
PAN_set_freq(); PAN_set_freq();
g_update_display = true; g_update_display = true;
} }
@ -151,52 +149,50 @@ void PAN_process_10ms(void)
if (g_current_function == FUNCTION_TRANSMIT) if (g_current_function == FUNCTION_TRANSMIT)
{ {
g_panadapter_vfo_mode = 100; // 1 sec - stay on the VFO frequency for at least this amount of time after PTT release g_panadapter_vfo_tick = 100; // 1 sec - stay on the VFO frequency for at least this amount of time after PTT release
panadapter_rssi_index = -1; panadapter_rssi_index = -1;
return; return;
} }
if (!g_panadapter_enabled) if (!g_panadapter_enabled)
{ // enable the panadapter { // enable the panadapter
g_panadapter_vfo_tick = 0;
#ifdef ENABLE_PANADAPTER_PEAK_FREQ
g_panadapter_peak_freq = 0;
#endif
g_panadapter_vfo_mode = 0;
// g_panadapter_max_rssi = 0;
// g_panadapter_min_rssi = 0;
// memset(g_panadapter_rssi, 0, sizeof(g_panadapter_rssi));
panadapter_rssi_index = 0; panadapter_rssi_index = 0;
panadapter_delay = 3; // give the VCO/PLL/RSSI more time to settle panadapter_delay = 3; // give the VCO/PLL/RSSI a little more time to settle
// g_panadapter_cycles = 0;
g_panadapter_enabled = true; g_panadapter_enabled = true;
PAN_set_freq(); PAN_set_freq();
g_update_display = true; g_update_display = true;
return; return;
} }
if (panadapter_rssi_index < 0) if (panadapter_rssi_index < 0)
{ { // guess we've just come out of TX mode
PAN_set_freq(); PAN_set_freq();
panadapter_rssi_index++; panadapter_rssi_index = 0;
return; return;
} }
if (g_panadapter_vfo_mode > 0) if (g_panadapter_vfo_tick > 0)
{ // we're paused on the VFO/center frequency { // we're paused on/monitoring the VFO/center frequency
// save the current RSSI value // save the current RSSI value into the center of the panadapter
const int16_t rssi = g_current_rssi[g_eeprom.config.setting.tx_vfo_num]; const int16_t rssi = g_current_rssi[g_eeprom.config.setting.tx_vfo_num];
g_panadapter_rssi[PANADAPTER_BINS] = (rssi > 255) ? 255 : (rssi < panadapter_min_rssi) ? panadapter_min_rssi : rssi; g_panadapter_rssi[PANADAPTER_BINS] = (rssi > 255) ? 255 : (rssi < panadapter_min_rssi) ? panadapter_min_rssi : rssi;
PAN_update_min_max(); PAN_update_min_max();
g_panadapter_vfo_mode = g_squelch_open ? 40 : g_panadapter_vfo_mode - 1; // stay on the VFO/center frequency for a further 400ms after carrier drop
g_panadapter_vfo_tick = g_squelch_open ? 40 : g_panadapter_vfo_tick - 1;
if (g_panadapter_vfo_mode <= 0) if (g_panadapter_vfo_tick <= 0)
{ { // back to scan/sweep mode
PAN_set_freq(); PAN_set_freq();
panadapter_delay = 3; // give the VCO/PLL/RSSI more time to settle panadapter_delay = 3; // give the VCO/PLL/RSSI a little more time to settle
if (g_panadapter_cycles > 0)
UI_DisplayMain_pan(true);
//g_update_display = true;
} }
return; return;
@ -205,12 +201,12 @@ void PAN_process_10ms(void)
// scanning/sweeping // scanning/sweeping
if (panadapter_delay > 0) if (panadapter_delay > 0)
{ { // let the VCO/PLL/RSSI settle before sampling the RSSI
panadapter_delay--; panadapter_delay--;
return; return;
} }
// save the current RSSI value // save the current RSSI value into the panadapter
const uint16_t rssi = BK4819_GetRSSI(); const uint16_t rssi = BK4819_GetRSSI();
g_panadapter_rssi[panadapter_rssi_index] = (rssi > 255) ? 255 : (rssi < panadapter_min_rssi) ? panadapter_min_rssi : rssi; g_panadapter_rssi[panadapter_rssi_index] = (rssi > 255) ? 255 : (rssi < panadapter_min_rssi) ? panadapter_min_rssi : rssi;
@ -218,22 +214,28 @@ void PAN_process_10ms(void)
if (++panadapter_rssi_index >= (int)ARRAY_SIZE(g_panadapter_rssi)) if (++panadapter_rssi_index >= (int)ARRAY_SIZE(g_panadapter_rssi))
{ {
panadapter_rssi_index = 0; panadapter_rssi_index = 0;
panadapter_delay = 3; // give the VCO/PLL/RSSI more time to settle panadapter_delay = 3; // give the VCO/PLL/RSSI a little more time to settle
} }
if (g_tx_vfo->channel.mod_mode == MOD_MODE_FM) if (g_tx_vfo->channel.mod_mode == MOD_MODE_FM)
{ // switch back to the VFO/center frequency for 100ms once every 400ms { // switch back to the VFO/center frequency for 100ms once every 400ms
g_panadapter_vfo_mode = ((panadapter_rssi_index % 40) == 0) ? 10 : 0; g_panadapter_vfo_tick = ((panadapter_rssi_index % 40) == 0) ? 10 : 0;
} }
else else
{ // switch back to the VFO/center frequency for 100ms once per full sweep/scan cycle { // switch back to the VFO/center frequency for 100ms once per full sweep/scan cycle
g_panadapter_vfo_mode = (panadapter_rssi_index == 0) ? 10 : 0; g_panadapter_vfo_tick = (panadapter_rssi_index == 0) ? 10 : 0;
} }
// set the VCO/PLL frequency
PAN_set_freq(); PAN_set_freq();
if (panadapter_rssi_index == 0) if (panadapter_rssi_index != 0)
{ // the last bin value .. only draw the panadapter once per full sweep/scan cycle return;
// completed a full sweep/scan, draw the panadapter on-screen
if (g_panadapter_cycles + 1)
g_panadapter_cycles++;
PAN_update_min_max(); PAN_update_min_max();
@ -244,4 +246,3 @@ void PAN_process_10ms(void)
UI_DisplayMain_pan(true); UI_DisplayMain_pan(true);
//g_update_display = true; //g_update_display = true;
} }
}

View File

@ -29,8 +29,9 @@
#define PANADAPTER_MIN_STEP 625 #define PANADAPTER_MIN_STEP 625
extern bool g_panadapter_enabled; extern bool g_panadapter_enabled;
extern unsigned int g_panadapter_cycles;
extern uint32_t g_panadapter_peak_freq; extern uint32_t g_panadapter_peak_freq;
extern int g_panadapter_vfo_mode; extern int g_panadapter_vfo_tick;
extern uint8_t g_panadapter_rssi[PANADAPTER_BINS + 1 + PANADAPTER_BINS]; extern uint8_t g_panadapter_rssi[PANADAPTER_BINS + 1 + PANADAPTER_BINS];
extern uint8_t g_panadapter_max_rssi; extern uint8_t g_panadapter_max_rssi;
extern uint8_t g_panadapter_min_rssi; extern uint8_t g_panadapter_min_rssi;

View File

@ -431,6 +431,8 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
} }
// auto vertical scale // auto vertical scale
if (g_panadapter_cycles > 0)
{
max_rssi = g_panadapter_max_rssi; max_rssi = g_panadapter_max_rssi;
min_rssi = g_panadapter_min_rssi; min_rssi = g_panadapter_min_rssi;
span_rssi = max_rssi - min_rssi; span_rssi = max_rssi - min_rssi;
@ -441,6 +443,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
min_rssi = 255 - span_rssi; min_rssi = 255 - span_rssi;
max_rssi = min_rssi + span_rssi; max_rssi = min_rssi + span_rssi;
} }
}
if (now) if (now)
{ // clear our assigned screen area { // clear our assigned screen area
@ -448,7 +451,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
} }
#ifdef ENABLE_PANADAPTER_PEAK_FREQ #ifdef ENABLE_PANADAPTER_PEAK_FREQ
if (g_panadapter_peak_freq > 0) if (g_panadapter_peak_freq > 0 && g_panadapter_cycles > 0)
{ // print the peak frequency { // print the peak frequency
char str[16]; char str[16];
sprintf(str, "%u.%05u", g_panadapter_peak_freq / 100000, g_panadapter_peak_freq % 100000); sprintf(str, "%u.%05u", g_panadapter_peak_freq / 100000, g_panadapter_peak_freq % 100000);
@ -458,7 +461,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
#endif #endif
// draw top center vertical marker (the VFO frequency) // draw top center vertical marker (the VFO frequency)
base_line[PANADAPTER_BINS - (LCD_WIDTH * 2)] = 0x1F; base_line[PANADAPTER_BINS - (LCD_WIDTH * 2)] = 0x3F;
// draw top horizontal dotted line // draw top horizontal dotted line
for (i = 0; i < PANADAPTER_BINS; i += 4) for (i = 0; i < PANADAPTER_BINS; i += 4)
@ -469,6 +472,8 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
} }
// draw the panadapter vertical bins // draw the panadapter vertical bins
if (g_panadapter_cycles > 0)
{
for (i = 0; i < ARRAY_SIZE(g_panadapter_rssi); i++) for (i = 0; i < ARRAY_SIZE(g_panadapter_rssi); i++)
{ {
uint32_t pixels; uint32_t pixels;
@ -492,6 +497,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
base_line[i - (LCD_WIDTH * 1)] |= bit_reverse_8(pixels >> 8); base_line[i - (LCD_WIDTH * 1)] |= bit_reverse_8(pixels >> 8);
base_line[i - (LCD_WIDTH * 0)] |= bit_reverse_8(pixels >> 0); base_line[i - (LCD_WIDTH * 0)] |= bit_reverse_8(pixels >> 0);
} }
}
if (now) if (now)
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();