0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-18 22:29:50 +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

@ -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