mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-19 06:39:49 +03:00
Added freq cal menu option (hidden) + 8.33kHz step bug fix
This commit is contained in:
37
app/app.c
37
app/app.c
@ -475,15 +475,30 @@ void APP_StartListening(FUNCTION_Type_t Function)
|
||||
|
||||
void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
|
||||
{
|
||||
uint32_t Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency);
|
||||
uint32_t Frequency;
|
||||
|
||||
Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency);
|
||||
|
||||
if (pInfo->StepFrequency == 833)
|
||||
{
|
||||
const uint32_t Lower = LowerLimitFrequencyBandTable[pInfo->Band];
|
||||
const uint32_t Delta = Frequency - Lower;
|
||||
uint32_t Base = (Delta / 2500) * 2500;
|
||||
const uint32_t Index = ((Delta - Base) % 2500) / 833;
|
||||
|
||||
if (Index == 2)
|
||||
Base++;
|
||||
|
||||
Frequency = Lower + Base + (Index * 833);
|
||||
}
|
||||
|
||||
if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band])
|
||||
Frequency = FREQUENCY_FloorToStep(UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, LowerLimitFrequencyBandTable[pInfo->Band]);
|
||||
else
|
||||
if (Frequency > UpperLimitFrequencyBandTable[pInfo->Band])
|
||||
Frequency = LowerLimitFrequencyBandTable[pInfo->Band];
|
||||
|
||||
pInfo->ConfigRX.Frequency = Frequency;
|
||||
pInfo->ConfigRX.Frequency = LowerLimitFrequencyBandTable[pInfo->Band];
|
||||
else
|
||||
if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band])
|
||||
pInfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, LowerLimitFrequencyBandTable[pInfo->Band]);
|
||||
else
|
||||
pInfo->ConfigRX.Frequency = Frequency;
|
||||
}
|
||||
|
||||
static void FREQ_NextChannel(void)
|
||||
@ -614,6 +629,14 @@ void APP_CheckRadioInterrupts(void)
|
||||
// fetch the interrupt status bits
|
||||
interrupt_status_bits = BK4819_ReadRegister(BK4819_REG_02);
|
||||
|
||||
// 0 = no phase shift
|
||||
// 1 = 120deg phase shift
|
||||
// 2 = 180deg phase shift
|
||||
// 3 = 240deg phase shift
|
||||
// const uint8_t ctcss_shift = BK4819_GetCTCShift();
|
||||
// if (ctcss_shift > 0)
|
||||
// g_CTCSS_Lost = true;
|
||||
|
||||
if (interrupt_status_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
|
||||
{
|
||||
gDTMF_RequestPending = true;
|
||||
|
75
app/menu.c
75
app/menu.c
@ -24,6 +24,8 @@
|
||||
#include "board.h"
|
||||
#include "bsp/dp32g030/gpio.h"
|
||||
#include "driver/backlight.h"
|
||||
#include "driver/bk4819.h"
|
||||
#include "driver/eeprom.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/keyboard.h"
|
||||
#include "frequencies.h"
|
||||
@ -61,9 +63,9 @@
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_BEEP_PROMPT,
|
||||
VOICE_ID_TRANSMIT_OVER_TIME,
|
||||
// #ifdef ENABLE_VOICE
|
||||
#ifdef ENABLE_VOICE
|
||||
VOICE_ID_VOICE_PROMPT,
|
||||
// #endif
|
||||
#endif
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
@ -72,6 +74,9 @@
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
#ifdef ENABLE_COMPANDER
|
||||
VOICE_ID_INVALID,
|
||||
#endif
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
@ -98,11 +103,16 @@
|
||||
#endif
|
||||
VOICE_ID_DELETE_CHANNEL,
|
||||
VOICE_ID_INITIALISATION,
|
||||
|
||||
// hidden items
|
||||
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
VOICE_ID_INVALID,
|
||||
|
||||
VOICE_ID_INVALID
|
||||
};
|
||||
#endif
|
||||
@ -127,7 +137,7 @@ void MENU_StopCssScan(void)
|
||||
RADIO_SetupRegisters(true);
|
||||
}
|
||||
|
||||
int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
|
||||
int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
|
||||
{
|
||||
switch (Cursor)
|
||||
{
|
||||
@ -304,7 +314,12 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
|
||||
*pMin = 1;
|
||||
*pMax = 16;
|
||||
break;
|
||||
|
||||
|
||||
case MENU_F_CALI:
|
||||
*pMin = -1000;
|
||||
*pMax = +1000;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@ -314,8 +329,8 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
|
||||
|
||||
void MENU_AcceptSetting(void)
|
||||
{
|
||||
uint8_t Min;
|
||||
uint8_t Max;
|
||||
int32_t Min;
|
||||
int32_t Max;
|
||||
uint8_t Code;
|
||||
FREQ_Config_t *pConfig = &gTxVfo->ConfigRX;
|
||||
|
||||
@ -656,7 +671,28 @@ void MENU_AcceptSetting(void)
|
||||
gRequestSaveSettings = true;
|
||||
gFlagReconfigureVfos = true;
|
||||
return;
|
||||
|
||||
|
||||
case MENU_F_CALI:
|
||||
gEeprom.BK4819_XTAL_FREQ_LOW = gSubMenuSelection;
|
||||
BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW);
|
||||
{
|
||||
struct
|
||||
{
|
||||
int16_t BK4819_XtalFreqLow;
|
||||
uint16_t EEPROM_1F8A;
|
||||
uint16_t EEPROM_1F8C;
|
||||
uint8_t VOLUME_GAIN;
|
||||
uint8_t DAC_GAIN;
|
||||
} __attribute__((packed)) Misc;
|
||||
|
||||
// radio 1 .. 04 00 46 00 50 00 2C 0E
|
||||
// radio 2 .. 05 00 46 00 50 00 2C 0E
|
||||
EEPROM_ReadBuffer(0x1F88, &Misc, 8);
|
||||
Misc.BK4819_XtalFreqLow = gEeprom.BK4819_XTAL_FREQ_LOW;
|
||||
EEPROM_WriteBuffer(0x1F88, &Misc);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -666,13 +702,14 @@ void MENU_AcceptSetting(void)
|
||||
|
||||
void MENU_SelectNextCode(void)
|
||||
{
|
||||
uint8_t UpperLimit;
|
||||
int32_t UpperLimit;
|
||||
|
||||
if (gMenuCursor == MENU_R_DCS)
|
||||
UpperLimit = 208;
|
||||
//UpperLimit = ARRAY_SIZE(DCS_Options);
|
||||
else
|
||||
if (gMenuCursor == MENU_R_CTCS)
|
||||
UpperLimit = 50;
|
||||
UpperLimit = ARRAY_SIZE(CTCSS_Options) - 1;
|
||||
else
|
||||
return;
|
||||
|
||||
@ -707,11 +744,11 @@ void MENU_SelectNextCode(void)
|
||||
|
||||
static void MENU_ClampSelection(int8_t Direction)
|
||||
{
|
||||
uint8_t Min;
|
||||
uint8_t Max;
|
||||
int32_t Min;
|
||||
int32_t Max;
|
||||
if (!MENU_GetLimits(gMenuCursor, &Min, &Max))
|
||||
{
|
||||
uint8_t Selection = gSubMenuSelection;
|
||||
int32_t Selection = gSubMenuSelection;
|
||||
if (Selection < Min) Selection = Min;
|
||||
else
|
||||
if (Selection > Max) Selection = Max;
|
||||
@ -976,6 +1013,10 @@ void MENU_ShowCurrentSetting(void)
|
||||
case MENU_SCREN:
|
||||
gSubMenuSelection = gSetting_ScrambleEnable;
|
||||
break;
|
||||
|
||||
case MENU_F_CALI:
|
||||
gSubMenuSelection = gEeprom.BK4819_XTAL_FREQ_LOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1073,8 +1114,8 @@ static void MENU_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t Min;
|
||||
uint8_t Max;
|
||||
int32_t Min;
|
||||
int32_t Max;
|
||||
|
||||
if (!MENU_GetLimits(gMenuCursor, &Min, &Max))
|
||||
{
|
||||
@ -1322,12 +1363,16 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
|
||||
case MENU_1_CALL:
|
||||
bCheckScanList = false;
|
||||
break;
|
||||
|
||||
case MENU_SLIST2:
|
||||
VFO = 1;
|
||||
|
||||
// Fallthrough
|
||||
|
||||
case MENU_SLIST1:
|
||||
bCheckScanList = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
MENU_ClampSelection(Direction);
|
||||
gRequestDisplayScreen = DISPLAY_MENU;
|
||||
@ -1361,7 +1406,7 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
MENU_Key_MENU(bKeyPressed, bKeyHeld);
|
||||
break;
|
||||
case KEY_UP:
|
||||
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
|
||||
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax);
|
||||
int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax);
|
||||
void MENU_AcceptSetting(void);
|
||||
void MENU_SelectNextCode(void);
|
||||
void MENU_ShowCurrentSetting(void);
|
||||
|
Reference in New Issue
Block a user