0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-27 13:51:25 +03:00

added a panadapter

This commit is contained in:
OneOfEleven 2023-11-18 18:44:10 +00:00
parent fb9fdd6921
commit 04faeb1ee6
21 changed files with 411 additions and 1602 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 := 1
ENABLE_VOX := 0
ENABLE_VOX_MORE_SENSITIVE := 1
ENABLE_REDUCE_LOW_MID_TX_POWER := 1
# Tx Alarm 600 B
@ -59,7 +59,7 @@ ENABLE_DTMF_CALL_FLASH_LIGHT := 1
ENABLE_FLASH_LIGHT_SOS_TONE := 0
ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_FREQ_SEARCH_LNA := 1
ENABLE_FREQ_SEARCH_LNA := 0
ENABLE_FREQ_SEARCH_TIMEOUT := 0
ENABLE_CODE_SEARCH_TIMEOUT := 0
ENABLE_SCAN_IGNORE_LIST := 1
@ -82,7 +82,7 @@ ENABLE_TX_AUDIO_BAR := 0
ENABLE_SIDE_BUTT_MENU := 0
# Key Lock 400 B
ENABLE_KEYLOCK := 1
ENABLE_PANADAPTER := 0
ENABLE_PANADAPTER := 1
#ENABLE_SINGLE_VFO_CHAN := 0
#############################################################
@ -223,6 +223,9 @@ OBJS += ui/status.o
OBJS += ui/ui.o
OBJS += version.o
OBJS += main.o
ifeq ($(ENABLE_PANADAPTER),1)
OBJS += panadapter.o
endif
ifeq ($(OS), Windows_NT)
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))

View File

@ -95,7 +95,7 @@ ENABLE_RX_SIGNAL_BAR := 1 enable a menu option for showing an
ENABLE_TX_AUDIO_BAR := 1 enable a menu option for showing a TX audio level bar
ENABLE_SIDE_BUTT_MENU := 1 enable menu option for configuring the programmable side buttons
ENABLE_KEYLOCK := 1 enable keylock menu option + keylock code
#ENABLE_PANADAPTER := 0 not yet implemented - spectrum/pan-adapter
ENABLE_PANADAPTER := 1 TEST ONLY centered on the selected VFO RX frequency, only shows if dual-watch is disabled
#ENABLE_SINGLE_VFO_CHAN := 0 not yet implemented - single VFO on display when possible
```

View File

@ -59,6 +59,9 @@
#include "mdc1200.h"
#endif
#include "misc.h"
#ifdef ENABLE_PANADAPTER
#include "panadapter.h"
#endif
#include "radio.h"
#include "settings.h"
#if defined(ENABLE_OVERLAY)
@ -71,13 +74,6 @@
#include "ui/status.h"
#include "ui/ui.h"
// original QS front end register settings
// 0x03BE 00000 011 101 11 110
const uint8_t orig_lnas = 3; // 0dB
const uint8_t orig_lna = 5; // -4dB
const uint8_t orig_mixer = 3; // 0dB
const uint8_t orig_pga = 6; // -3dB
static void APP_process_key(const key_code_t Key, const bool key_pressed, const bool key_held);
static void APP_update_rssi(const int vfo, const bool force)
@ -88,8 +84,11 @@ static void APP_update_rssi(const int vfo, const bool force)
#ifdef ENABLE_AM_FIX
// add RF gain adjust compensation
if (g_current_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
rssi -= rssi_gain_diff[vfo];
#ifdef ENABLE_PANADAPTER
if (!g_pan_enabled || g_panadapter_vfo_mode > 0)
#endif
if (g_current_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
rssi -= rssi_gain_diff[vfo];
#endif
if (g_current_rssi[vfo] == rssi && !force)
@ -1841,6 +1840,11 @@ void APP_process_power_save(void)
{
bool power_save = true;
#ifdef ENABLE_PANADAPTER
if (g_eeprom.config.setting.panadapter)
power_save = false;
#endif
if (g_monitor_enabled ||
#ifdef ENABLE_FMRADIO
g_fm_radio_mode ||
@ -1861,8 +1865,8 @@ void APP_process_power_save(void)
#ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[0].screen) ||
IS_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[1].screen) ||
g_noaa_mode)
IS_NOAA_CHANNEL(g_eeprom.config.setting.indices.vfo[1].screen) ||
g_noaa_mode)
{
power_save = false;
}
@ -1872,6 +1876,7 @@ void APP_process_power_save(void)
{
// if (g_current_function == FUNCTION_POWER_SAVE && g_rx_idle_mode)
// BK4819_RX_TurnOn();
if (g_current_function == FUNCTION_POWER_SAVE)
FUNCTION_Select(FUNCTION_RECEIVE); // come out of power save mode
@ -2511,6 +2516,11 @@ void APP_time_slice_10ms(void)
}
#endif
#ifdef ENABLE_PANADAPTER
if (g_eeprom.config.setting.panadapter)
PAN_process_10ms();
#endif
APP_process_power_save();
APP_process_scan();

View File

@ -23,11 +23,6 @@
#include "frequencies.h"
#include "radio.h"
extern const uint8_t orig_lnas;
extern const uint8_t orig_lna;
extern const uint8_t orig_mixer;
extern const uint8_t orig_pga;
void APP_end_tx(void);
void APP_stop_scan(void);
void APP_channel_next(const bool remember_current, const scan_state_dir_t scan_direction);

View File

@ -43,6 +43,9 @@
#include "ui/inputbox.h"
#include "ui/menu.h"
#include "ui/menu.h"
#ifdef ENABLE_PANADAPTER
#include "panadapter.h"
#endif
#include "radio.h"
#include "settings.h"
#include "ui/ui.h"
@ -229,6 +232,9 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
#ifdef ENABLE_AM_FIX
// case MENU_AM_FIX:
#endif
#ifdef ENABLE_PANADAPTER
case MENU_PANADAPTER:
#endif
#ifdef ENABLE_TX_AUDIO_BAR
case MENU_TX_BAR:
#endif
@ -670,6 +676,13 @@ void MENU_AcceptSetting(void)
g_flag_reconfigure_vfos = true;
break;
#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
#ifdef ENABLE_TX_AUDIO_BAR
case MENU_TX_BAR:
g_eeprom.config.setting.mic_bar = g_sub_menu_selection;
@ -1095,11 +1108,11 @@ void MENU_ShowCurrentSetting(void)
g_sub_menu_selection = g_eeprom.config.setting.tx_timeout;
break;
#ifdef ENABLE_VOICE
#ifdef ENABLE_VOICE
case MENU_VOICE:
g_sub_menu_selection = g_eeprom.config.setting.voice_prompt;
break;
#endif
#endif
case MENU_SCAN_CAR_RESUME:
g_sub_menu_selection = g_eeprom.config.setting.carrier_search_mode;
@ -1141,17 +1154,23 @@ void MENU_ShowCurrentSetting(void)
g_sub_menu_selection = g_eeprom.config.setting.mic_sensitivity;
break;
#ifdef ENABLE_TX_AUDIO_BAR
#ifdef ENABLE_PANADAPTER
case MENU_PANADAPTER:
g_sub_menu_selection = g_eeprom.config.setting.panadapter;
break;
#endif
#ifdef ENABLE_TX_AUDIO_BAR
case MENU_TX_BAR:
g_sub_menu_selection = g_eeprom.config.setting.mic_bar;
break;
#endif
#endif
#ifdef ENABLE_RX_SIGNAL_BAR
#ifdef ENABLE_RX_SIGNAL_BAR
case MENU_RX_BAR:
g_sub_menu_selection = g_eeprom.config.setting.enable_rssi_bar;
break;
#endif
#endif
case MENU_COMPAND:
g_sub_menu_selection = g_tx_vfo->channel.compand;

File diff suppressed because it is too large Load Diff

View File

@ -1,203 +0,0 @@
/* Copyright 2023 fagci
* https://github.com/fagci
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPECTRUM_H
#define SPECTRUM_H
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "../bitmaps.h"
#include "../board.h"
#include "../bsp/dp32g030/gpio.h"
#include "../driver/bk4819-regs.h"
#include "../driver/bk4819.h"
#include "../driver/gpio.h"
#include "../driver/keyboard.h"
#include "../driver/st7565.h"
#include "../driver/system.h"
#include "../driver/systick.h"
#include "../external/printf/printf.h"
#include "../font.h"
#include "../frequencies.h"
#include "../helper/battery.h"
#include "../helper/measurements.h"
#include "../misc.h"
#include "../radio.h"
#include "../settings.h"
#include "../ui/helper.h"
static const uint8_t DrawingEndY = 40;
static const uint16_t scanStepValues[] = {
1, 10, 50, 100, 250, 500, 625, 833, 1000, 1250, 2500, 10000,
};
static const uint8_t gStepSettingToIndex[] = {
[STEP_2_5kHz] = 4, [STEP_5_0kHz] = 5, [STEP_6_25kHz] = 6,
[STEP_10_0kHz] = 8, [STEP_12_5kHz] = 9, [STEP_25_0kHz] = 10,
[STEP_8_33kHz] = 7,
};
static const uint16_t scanStepBWRegValues[12] = {
// RX RXw TX BW
// 0b0 000 000 001 01 1000
// 1
0b0000000001011000, // 6.25
// 10
0b0000000001011000, // 6.25
// 50
0b0000000001011000, // 6.25
// 100
0b0000000001011000, // 6.25
// 250
0b0000000001011000, // 6.25
// 500
0b0010010001011000, // 6.25
// 625
0b0100100001011000, // 6.25
// 833
0b0110110001001000, // 6.25
// 1000
0b0110110001001000, // 6.25
// 1250
0b0111111100001000, // 6.25
// 2500
0b0011011000101000, // 25
// 10000
0b0011011000101000, // 25
};
static const uint16_t listenBWRegValues[] = {
0b0011011000101000, // 25
0b0111111100001000, // 12.5
0b0100100001011000, // 6.25
};
typedef enum State {
SPECTRUM,
FREQ_INPUT,
STILL,
} State;
typedef enum StepsCount {
STEPS_128,
STEPS_64,
STEPS_32,
STEPS_16,
} StepsCount;
typedef enum ModulationType {
MOD_FM,
MOD_AM,
MOD_USB,
} ModulationType;
typedef enum ScanStep {
S_STEP_0_01kHz,
S_STEP_0_1kHz,
S_STEP_0_5kHz,
S_STEP_1_0kHz,
S_STEP_2_5kHz,
S_STEP_5_0kHz,
S_STEP_6_25kHz,
S_STEP_8_33kHz,
S_STEP_10_0kHz,
S_STEP_12_5kHz,
S_STEP_25_0kHz,
S_STEP_100_0kHz,
} ScanStep;
typedef struct SpectrumSettings {
StepsCount stepsCount;
ScanStep scanStepIndex;
uint32_t frequencyChangeStep;
uint16_t scanDelay;
uint16_t rssiTriggerLevel;
bool backlightState;
BK4819_FilterBandwidth_t bw;
BK4819_FilterBandwidth_t listenBw;
ModulationType modulationType;
} SpectrumSettings;
typedef struct KeyboardState {
KEY_Code_t current;
KEY_Code_t prev;
uint8_t counter;
} KeyboardState;
typedef struct ScanInfo {
uint16_t rssi, rssiMin, rssiMax;
uint8_t i, iPeak;
uint32_t f, fPeak;
uint16_t scanStep;
uint8_t measurementsCount;
} ScanInfo;
typedef struct RegisterSpec {
const char *name;
uint8_t num;
uint8_t offset;
uint16_t maxValue;
uint16_t inc;
} RegisterSpec;
typedef struct PeakInfo {
uint16_t t;
uint16_t rssi;
uint8_t i;
uint32_t f;
} PeakInfo;
typedef struct MovingAverage {
uint16_t mean[128];
uint16_t buf[4][128];
uint16_t min, mid, max;
uint16_t t;
} MovingAverage;
typedef struct FreqPreset {
char name[16];
uint32_t fStart;
uint32_t fEnd;
StepsCount stepsCountIndex;
uint8_t stepSizeIndex;
ModulationType modulationType;
BK4819_FilterBandwidth_t listenBW;
} FreqPreset;
static const FreqPreset freqPresets[] = {
{"17m", 1806800, 1831800, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
{"15m", 2100000, 2145000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
{"12m", 2489000, 2514000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
{"CB", 2697500, 2785500, STEPS_128, S_STEP_5_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"10m", 2800000, 2970000, STEPS_128, S_STEP_1_0kHz, MOD_USB, BK4819_FILTER_BW_NARROWER},
{"AIR", 11800000, 13500000, STEPS_128, S_STEP_100_0kHz, MOD_AM, BK4819_FILTER_BW_NARROW },
{"2m", 14400000, 14600000, STEPS_128, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"JD1", 15175000, 15400000, STEPS_128, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"JD2", 15500000, 15600000, STEPS_64, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"LPD", 43307500, 43477500, STEPS_128, S_STEP_25_0kHz, MOD_FM, BK4819_FILTER_BW_WIDE },
{"PMR", 44600625, 44620000, STEPS_16, S_STEP_12_5kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"FRS/GM 462", 46256250, 46272500, STEPS_16, S_STEP_12_5kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
{"FRS/GM 467", 46756250, 46771250, STEPS_16, S_STEP_12_5kHz, MOD_FM, BK4819_FILTER_BW_NARROW },
};
void APP_RunSpectrum(void);
#endif

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,4 @@
#include <stdlib.h> // abs()
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h"
#endif

7
main.c
View File

@ -44,6 +44,9 @@
#include "mdc1200.h"
#endif
#include "misc.h"
#ifdef ENABLE_PANADAPTER
#include "panadapter.h"
#endif
#include "radio.h"
#include "settings.h"
#include "ui/helper.h"
@ -240,6 +243,10 @@ 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);

7
misc.c
View File

@ -231,6 +231,13 @@ int16_t g_current_rssi[2];
uint16_t g_current_glitch[2];
uint16_t g_current_noise[2];
// original QS front end register settings
// 0x03BE 00000 011 101 11 110
const uint8_t g_orig_lnas = 3; // 0dB
const uint8_t g_orig_lna = 5; // -4dB
const uint8_t g_orig_mixer = 3; // 0dB
const uint8_t g_orig_pga = 6; // -3dB
// ***************************
unsigned int get_RX_VFO(void)

5
misc.h
View File

@ -321,6 +321,11 @@ extern volatile uint16_t g_boot_tick_10ms;
extern uint8_t g_mic_sensitivity_tuning;
extern const uint8_t g_orig_lnas;
extern const uint8_t g_orig_lna;
extern const uint8_t g_orig_mixer;
extern const uint8_t g_orig_pga;
unsigned int get_TX_VFO(void);
unsigned int get_RX_VFO(void);
void NUMBER_Get(char *pDigits, uint32_t *pInteger);

138
panadapter.c Normal file
View File

@ -0,0 +1,138 @@
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
#include "driver/uart.h"
#endif
#include "panadapter.h"
#ifdef ENABLE_FMRADIO
#include "app/fm.h"
#endif
#include "driver/bk4819.h"
#include "functions.h"
#include "misc.h"
#include "radio.h"
#include "settings.h"
#include "ui/main.h"
#include "ui/ui.h"
bool g_pan_enabled = false;
// a list of frequencies to ignore/skip when scanning
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
void PAN_set_freq(void)
{ // set the frequency
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)
{ // panadapter mode .. add the bin offset
if (g_panadapter_rssi_index < PANADAPTER_BINS)
freq -= step_size * (PANADAPTER_BINS - g_panadapter_rssi_index);
else
if (g_panadapter_rssi_index > PANADAPTER_BINS)
freq += step_size * (g_panadapter_rssi_index - PANADAPTER_BINS);
}
BK4819_set_rf_frequency(freq, true); // set the VCO/PLL
//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);
#endif
}
void PAN_enable(const bool enable)
{
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_pan_enabled)
{
PAN_clear();
g_panadapter_vfo_mode = 1;
PAN_set_freq();
g_pan_enabled = false;
g_update_display = true;
}
}
}
bool PAN_process_10ms(void)
{
if (!g_pan_enabled)
return false;
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;
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;
#ifdef ENABLE_FMRADIO
if (g_fm_radio_mode)
return false;
#endif
if (g_squelch_open || g_monitor_enabled)
return false;
if (g_panadapter_vfo_mode <= 0)
{ // save the current RSSI value
const uint16_t rssi = BK4819_GetRSSI();
g_panadapter_rssi[g_panadapter_rssi_index] = (rssi <= 255) ? rssi : 255;
}
if (g_panadapter_vfo_mode <= 0)
{
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
g_panadapter_vfo_mode = ((g_panadapter_rssi_index & 15u) == 0) ? 1 : 0;
}
else
if (++g_panadapter_vfo_mode >= 8)
{
g_panadapter_vfo_mode = 0;
}
PAN_set_freq();
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;
}

37
panadapter.h Normal file
View File

@ -0,0 +1,37 @@
/* Copyright 2023 One of Eleven
* https://github.com/DualTachyon
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PANADAPTER_H
#define PANADAPTER_H
#include <stdint.h>
#include <stdbool.h>
#include "driver/st7565.h"
// number of bins either side of the VFO RX frequency
#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;
void PAN_clear(void);
void PAN_enable(const bool enable);
bool PAN_process_10ms(void);
#endif

36
radio.c
View File

@ -40,6 +40,9 @@
#include "mdc1200.h"
#endif
#include "misc.h"
#ifdef ENABLE_PANADAPTER
#include "panadapter.h"
#endif
#include "radio.h"
#include "settings.h"
#include "ui/menu.h"
@ -353,24 +356,49 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
#ifdef ENABLE_AM_FIX
AM_fix_reset(VFO);
if (p_vfo->channel.mod_mode != MOD_MODE_FM && g_eeprom.config.setting.am_fix)
{
AM_fix_10ms(VFO);
#ifdef ENABLE_PANADAPTER
if (!g_pan_enabled || g_panadapter_vfo_mode > 0)
{
AM_fix_10ms(VFO);
}
else
{ // don't do agc
BK4819_DisableAGC();
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
}
#else
AM_fix_10ms(VFO);
#endif
}
else
{ // don't do agc in FM mode
BK4819_DisableAGC();
BK4819_write_reg(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
}
#else
if (p_vfo->mod_mode != MOD_MODE_FM)
{
BK4819_EnableAGC();
#ifdef ENABLE_PANADAPTER
if (!g_pan_enabled || g_panadapter_vfo_mode > 0)
{
BK4819_EnableAGC();
}
else
{ // don't do agc
BK4819_DisableAGC();
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
}
#else
BK4819_EnableAGC();
#endif
}
else
{ // don't do agc in FM mode
BK4819_DisableAGC();
BK4819_write_reg(0x13, (orig_lnas << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
BK4819_write_reg(0x13, (g_orig_lnas << 8) | (g_orig_lna << 5) | (g_orig_mixer << 3) | (g_orig_pga << 0));
}
#endif

View File

@ -362,9 +362,17 @@ typedef struct {
uint32_t power_on_password; //
#ifdef ENABLE_MDC1200
uint16_t mdc1200_id; // 1of11
uint8_t unused6[2]; // 0xff's
uint8_t unused6[1]; // 0xff's
#else
uint8_t unused6[4]; // 0xff's
uint8_t unused6[3]; // 0xff's
#endif
#ifdef ENABLE_PANADAPTER
struct {
uint8_t panadapter:1; // 1 = enable panadapter
uint8_t unused6a:7; // 0xff
};
#else
uint8_t unused6a; // 0xff
#endif
// 0x0EA0

110
ui/main.c
View File

@ -34,6 +34,9 @@
#include "mdc1200.h"
#endif
#include "misc.h"
#ifdef ENABLE_PANADAPTER
#include "panadapter.h"
#endif
#include "radio.h"
#include "settings.h"
#include "ui/helper.h"
@ -50,6 +53,8 @@
const int rssi_offset_band_123 = -44;
const int rssi_offset_band_4567 = -18;
int single_vfo = -1;
center_line_t g_center_line = CENTER_LINE_NONE;
// ***************************************************************************
@ -393,6 +398,96 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int
#endif
}
#ifdef ENABLE_PANADAPTER
uint8_t bit_reverse_8(uint8_t n)
{
n = ((n >> 1) & 0x55) | ((n << 1) & 0xAA);
n = ((n >> 2) & 0x33) | ((n << 2) & 0xCC);
n = ((n >> 4) & 0x0F) | ((n << 4) & 0xF0);
return n;
}
void UI_DisplayMain_pan(const bool now)
{
const unsigned int line = (g_eeprom.config.setting.tx_vfo_num == 0) ? 4 : 0;
uint8_t *base_line = g_frame_buffer[line + 2];
uint8_t max_rssi = g_panadapter_rssi[0];
uint8_t min_rssi = g_panadapter_rssi[0];
uint8_t span_rssi;
unsigned int i;
if (!g_eeprom.config.setting.panadapter)
return;
if (!g_pan_enabled || single_vfo < 0 || g_current_display_screen != DISPLAY_MAIN)
return;
if (g_squelch_open || g_monitor_enabled)
return;
for (i = 1; i < ARRAY_SIZE(g_panadapter_rssi); i++)
{
const uint8_t rssi = g_panadapter_rssi[i];
if (max_rssi < rssi)
max_rssi = rssi;
if (min_rssi > rssi)
min_rssi = rssi;
}
span_rssi = max_rssi - min_rssi;
if (span_rssi < 20) // minimum vertical range
{
span_rssi = 20;
if (min_rssi > (255 - span_rssi))
min_rssi = 255 - span_rssi;
max_rssi = min_rssi + span_rssi;
}
if (now)
{
memset(g_frame_buffer[line + 0], 0, LCD_WIDTH);
memset(g_frame_buffer[line + 1], 0, LCD_WIDTH);
memset(g_frame_buffer[line + 2], 0, LCD_WIDTH);
}
for (i = 0; i < ARRAY_SIZE(g_panadapter_rssi); i++)
{
uint8_t rssi = g_panadapter_rssi[i];
uint32_t pixels;
#if 0
rssi = (rssi < ((-129 + 160) * 2)) ? 0 : rssi - ((-129 + 160) * 2); // min of -129dBm (S3)
rssi = rssi >> 2;
#else
rssi = ((rssi - min_rssi) * 22) / span_rssi; // 0 ~ 21
#endif
rssi += 2;
if (rssi > 21)
rssi = 21;
pixels = (1u << rssi) - 1;
pixels &= 0xfffffffe;
base_line[i - (LCD_WIDTH * 2)] = bit_reverse_8(pixels >> 16);
base_line[i - (LCD_WIDTH * 1)] = bit_reverse_8(pixels >> 8);
base_line[i - (LCD_WIDTH * 0)] = bit_reverse_8(pixels >> 0);
}
// center marker (the VFO frequency)
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)
base_line[i - (LCD_WIDTH * 2)] |= 1u;
// sprintf(str, "r %3d g %3u n %3u", rssi, glitch, noise);
// UI_PrintStringSmall(str, 2, 0, line);
if (now)
ST7565_BlitFullScreen();
}
#endif
void UI_DisplayMain(void)
{
#if !defined(ENABLE_BIG_FREQ) && defined(ENABLE_SMALLEST_FONT)
@ -400,7 +495,6 @@ void UI_DisplayMain(void)
#endif
const unsigned int line0 = 0; // text screen line
const unsigned int line1 = 4;
int single_vfo = -1;
int main_vfo_num = g_eeprom.config.setting.tx_vfo_num;
int current_vfo_num = g_eeprom.config.setting.tx_vfo_num;
char str[22];
@ -408,11 +502,16 @@ void UI_DisplayMain(void)
g_center_line = CENTER_LINE_NONE;
single_vfo = -1;
if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF && g_rx_vfo_is_active)
current_vfo_num = g_rx_vfo_num; // we're currently monitoring the other VFO
// if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF && g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF)
// single_vfo = g_eeprom.config.setting.tx_vfo_num;
#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;
#endif
// clear the screen
memset(g_frame_buffer, 0, sizeof(g_frame_buffer));
@ -636,6 +735,7 @@ void UI_DisplayMain(void)
const unsigned int x = 32;
uint32_t frequency = g_vfo_info[vfo_num].p_rx->frequency;
if (g_current_function == FUNCTION_TRANSMIT)
{ // transmitting
current_vfo_num = (g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) ? g_rx_vfo_num : g_eeprom.config.setting.tx_vfo_num;
@ -1038,6 +1138,10 @@ void UI_DisplayMain(void)
}
}
#ifdef ENABLE_PANADAPTER
UI_DisplayMain_pan(false);
#endif
ST7565_BlitFullScreen();
}

View File

@ -35,6 +35,9 @@ extern center_line_t g_center_line;
bool UI_DisplayAudioBar(const bool now);
#endif
void UI_update_rssi(const int rssi, const unsigned int glitch, const unsigned int noise, const unsigned int vfo);
#ifdef ENABLE_PANADAPTER
void UI_DisplayMain_pan(const bool now);
#endif
void UI_DisplayMain(void);
#endif

View File

@ -94,6 +94,9 @@ const t_menu_item g_menu_list[] =
{"RP STE", VOICE_ID_INVALID, MENU_RP_STE },
{"MIC GN", VOICE_ID_INVALID, MENU_MIC_GAIN },
{"COMPND", VOICE_ID_INVALID, MENU_COMPAND },
#ifdef ENABLE_PANADAPTER
{"PANA", VOICE_ID_INVALID, MENU_PANADAPTER },
#endif
#ifdef ENABLE_TX_AUDIO_BAR
{"Tx BAR", VOICE_ID_INVALID, MENU_TX_BAR },
#endif
@ -760,6 +763,12 @@ void UI_DisplayMenu(void)
break;
#endif
#ifdef ENABLE_PANADAPTER
case MENU_PANADAPTER:
strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);
break;
#endif
#ifdef ENABLE_TX_AUDIO_BAR
case MENU_TX_BAR:
strcpy(str, g_sub_menu_off_on[g_sub_menu_selection]);

View File

@ -84,6 +84,9 @@ enum
MENU_RP_STE,
MENU_MIC_GAIN,
MENU_COMPAND,
#ifdef ENABLE_PANADAPTER
MENU_PANADAPTER,
#endif
#ifdef ENABLE_TX_AUDIO_BAR
MENU_TX_BAR,
#endif