Refactoring

This commit is contained in:
Krzysiek Egzmont
2023-12-03 01:50:28 +01:00
parent 9ca3ccd744
commit e2b81bf9c8
4 changed files with 16 additions and 26 deletions

View File

@@ -30,7 +30,7 @@ ENABLE_TX_WHEN_AM := 0
ENABLE_F_CAL_MENU := 0
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 0
ENABLE_BOOT_BEEPS := 0
ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 0
ENABLE_NO_CODE_SCAN_TIMEOUT := 1
ENABLE_AM_FIX := 1

View File

@@ -446,6 +446,8 @@ static void HandleFunction(void)
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
{
(void)reset_am_fix;
const unsigned int chan = gEeprom.RX_VFO;
// const unsigned int chan = gRxVfo->CHANNEL_SAVE;
@@ -499,31 +501,13 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gUpdateStatus = true;
}
{ // RF RX front end gain
// original QS front end register settings
// 0x03BE 00000 011 101 11 110
const uint8_t orig_lna_short = 3; // 0dB
const uint8_t orig_lna = 5; // -4dB
const uint8_t orig_mixer = 3; // 0dB
const uint8_t orig_pga = 6; // -3dB
#ifdef ENABLE_AM_FIX
BK4819_SetAGC(gRxVfo->Modulation != MODULATION_AM || !gSetting_AM_fix);
if (gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix) { // AM RX mode
if (reset_am_fix)
AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency
AM_fix_10ms(chan);
}
else { // FM RX mode
BK4819_WriteRegister(BK4819_REG_13, (orig_lna_short << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
}
#else
(void)reset_am_fix;
BK4819_WriteRegister(BK4819_REG_13, (orig_lna_short << 8) | (orig_lna << 5) | (orig_mixer << 3) | (orig_pga << 0));
#endif
}
// AF gain - original QS values
// if (gRxVfo->Modulation != MODULATION_FM){

View File

@@ -489,8 +489,6 @@ static void ToggleModulation() {
settings.modulationType = MODULATION_FM;
}
RADIO_SetModulation(settings.modulationType);
BK4819_SetAGC(settings.modulationType != MODULATION_AM || !gSetting_AM_fix);
BK4819_InitAGC();
RelaunchScan();
redrawScreen = true;
}
@@ -1156,7 +1154,8 @@ static void Tick() {
void APP_RunSpectrum() {
// TX here coz it always? set to active VFO
vfo = gEeprom.TX_VFO;
currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency - ((GetStepsCount()/2) * GetScanStep()); //set the current frequency in the middle of the display
//set the current frequency in the middle of the display
currentFreq = initialFreq = gEeprom.VfoInfo[vfo].pRX->Frequency - ((GetStepsCount()/2) * GetScanStep());
BackupRegisters();
@@ -1167,7 +1166,6 @@ void APP_RunSpectrum() {
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
RADIO_SetModulation(settings.modulationType = gRxVfo->Modulation);
BK4819_SetAGC(settings.modulationType != MODULATION_AM || !gSetting_AM_fix);
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
RelaunchScan();

View File

@@ -889,6 +889,7 @@ void RADIO_SetTxParameters(void)
void RADIO_SetModulation(ModulationMode_t modulation)
{
static ModulationMode_t m = MODULATION_UKNOWN;
BK4819_AF_Type_t mod;
switch(modulation) {
default:
@@ -913,9 +914,16 @@ void RADIO_SetModulation(ModulationMode_t modulation)
}
BK4819_SetAF(mod);
if(m != modulation) {
m = modulation;
BK4819_SetRegValue(afDacGainRegSpec, 0xF);
BK4819_WriteRegister(BK4819_REG_3D, modulation == MODULATION_USB ? 0 : 0x2AAB);
BK4819_SetRegValue(afcDisableRegSpec, modulation != MODULATION_FM);
#ifdef ENABLE_AM_FIX
BK4819_SetAGC(modulation != MODULATION_AM || !gSetting_AM_fix);
BK4819_InitAGC();
#endif
}
}
void RADIO_SetVfoState(VfoState_t State)