Improve AM-fix

This commit is contained in:
Krzysiek Egzmont
2023-12-04 23:35:12 +01:00
parent f3297c29cb
commit 86438ef3ce
8 changed files with 146 additions and 147 deletions

View File

@@ -80,7 +80,7 @@ void ACTION_Monitor(void)
gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST;
#endif
RADIO_SetupRegisters(true);
APP_StartListening(FUNCTION_MONITOR, false);
APP_StartListening(FUNCTION_MONITOR);
return;
}

View File

@@ -230,7 +230,7 @@ static void HandleIncoming(void)
}
#endif
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, false);
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
}
static void HandleReceive(void)
@@ -444,12 +444,9 @@ static void HandleFunction(void)
}
}
void APP_StartListening(FUNCTION_Type_t function, const bool reset_am_fix)
void APP_StartListening(FUNCTION_Type_t function)
{
(void)reset_am_fix;
const unsigned int vfo = gEeprom.RX_VFO;
// const unsigned int chan = gRxVfo->CHANNEL_SAVE;
#ifdef ENABLE_DTMF_CALLING
if (gSetting_KILLED)
@@ -501,14 +498,6 @@ void APP_StartListening(FUNCTION_Type_t function, const bool reset_am_fix)
gUpdateStatus = true;
}
#ifdef ENABLE_AM_FIX
if (gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix) { // AM RX mode
if (reset_am_fix)
AM_fix_reset(vfo); // TODO: only reset it when moving channel/frequency
AM_fix_10ms(vfo);
}
#endif
BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1
@@ -1169,7 +1158,7 @@ void APP_TimeSlice10ms(void)
#ifdef ENABLE_AM_FIX
if (gRxVfo->Modulation == MODULATION_AM && gSetting_AM_fix)
AM_fix_10ms(gEeprom.RX_VFO);
AM_fix_10ms(gEeprom.RX_VFO, false);
#endif
if (UART_IsCommandAvailable())

View File

@@ -24,7 +24,7 @@
#include "radio.h"
void APP_EndTransmission(void);
void APP_StartListening(FUNCTION_Type_t function, const bool reset_am_fix);
void APP_StartListening(FUNCTION_Type_t function);
uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper);
uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction);
void APP_Update(void);

View File

@@ -71,14 +71,14 @@ void CHFRSCANNER_ContinueScanning(void)
if (IS_FREQ_CHANNEL(gNextMrChannel))
{
if (gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
else
NextFreqChannel(); // switch to next frequency
}
else
{
if (gCurrentCodeType == CODE_TYPE_OFF && gCurrentFunction == FUNCTION_INCOMING)
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true);
APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE);
else
NextMemChannel(); // switch to next channel
}

View File

@@ -282,11 +282,15 @@ uint16_t GetRssi() {
while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) {
SYSTICK_DelayUs(100);
}
#ifdef ENABLE_AM_FIX
if(settings.modulationType == MODULATION_AM) {
//return the corrected RSSI to allow for AM_Fixs AGC action.
return BK4819_GetRSSI() - AM_fix_get_rssi_gain_diff(vfo);
}
else {
else
#endif
{
return BK4819_GetRSSI();
}
@@ -488,6 +492,10 @@ static void ToggleModulation() {
settings.modulationType = MODULATION_FM;
}
RADIO_SetModulation(settings.modulationType);
if(settings.modulationType != MODULATION_AM) {
BK4819_InitAGC();
BK4819_SetAGC(1);
}
RelaunchScan();
redrawScreen = true;
}
@@ -1118,11 +1126,12 @@ static void UpdateListening() {
}
static void Tick() {
#ifdef ENABLE_AM_FIX
if(settings.modulationType == MODULATION_AM) {
AM_fix_10ms(vfo, true); //allow AM_Fix to apply its AGC action
}
#endif
if(settings.modulationType == MODULATION_AM)
{
AM_fix_10ms(vfo); //allow AM_Fix to apply its AGC action
}
if (!preventKeypress) {
HandleUserInput();
}
@@ -1165,6 +1174,14 @@ void APP_RunSpectrum() {
ToggleRX(true), ToggleRX(false); // hack to prevent noise when squelch off
RADIO_SetModulation(settings.modulationType = gRxVfo->Modulation);
#ifdef ENABLE_AM_FIX
if(settings.modulationType != MODULATION_AM) {
BK4819_InitAGC();
BK4819_SetAGC(1);
}
#endif
BK4819_SetFilterBandwidth(settings.listenBw = BK4819_FILTER_BW_WIDE, false);
RelaunchScan();