FIX #185: Allow manual changing of gain values in spectrum when AM fix is active

This commit is contained in:
Krzysiek Egzmont
2023-12-05 00:45:22 +01:00
parent 86438ef3ce
commit ed395ab638

View File

@@ -45,6 +45,7 @@ bool redrawScreen = false;
bool newScanStart = true; bool newScanStart = true;
bool preventKeypress = true; bool preventKeypress = true;
bool audioState = true; bool audioState = true;
bool lockAGC = false;
State currentState = SPECTRUM, previousState = SPECTRUM; State currentState = SPECTRUM, previousState = SPECTRUM;
@@ -112,10 +113,20 @@ static uint16_t GetRegMenuValue(uint8_t st) {
return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask; return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask;
} }
void LockAGC()
{
if(!lockAGC)
BK4819_SetAGC(0);
lockAGC = true;
}
static void SetRegMenuValue(uint8_t st, bool add) { static void SetRegMenuValue(uint8_t st, bool add) {
uint16_t v = GetRegMenuValue(st); uint16_t v = GetRegMenuValue(st);
RegisterSpec s = registerSpecs[st]; RegisterSpec s = registerSpecs[st];
if(s.num == BK4819_REG_13)
LockAGC();
uint16_t reg = BK4819_ReadRegister(s.num); uint16_t reg = BK4819_ReadRegister(s.num);
if (add && v <= s.mask - s.inc) { if (add && v <= s.mask - s.inc) {
v += s.inc; v += s.inc;
@@ -908,6 +919,7 @@ void OnKeyDownStill(KEY_Code_t key) {
case KEY_EXIT: case KEY_EXIT:
if (!menuState) { if (!menuState) {
SetState(SPECTRUM); SetState(SPECTRUM);
lockAGC = false;
monitorMode = false; monitorMode = false;
RelaunchScan(); RelaunchScan();
break; break;
@@ -1128,7 +1140,7 @@ static void UpdateListening() {
static void Tick() { static void Tick() {
#ifdef ENABLE_AM_FIX #ifdef ENABLE_AM_FIX
if(settings.modulationType == MODULATION_AM) { if(settings.modulationType == MODULATION_AM) {
AM_fix_10ms(vfo, true); //allow AM_Fix to apply its AGC action AM_fix_10ms(vfo, !lockAGC); //allow AM_Fix to apply its AGC action
} }
#endif #endif