Skip to content

Commit

Permalink
Fix egzumer#314:Reset current bar when blacklisting in scan range
Browse files Browse the repository at this point in the history
  • Loading branch information
egzumer committed Dec 22, 2023
1 parent 39eb3e8 commit 2cc60da
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions app/spectrum.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,19 +423,24 @@ static void UpdatePeakInfo() {
UpdatePeakInfoForce();
}

static void Measure()
{
uint16_t rssi = scanInfo.rssi = GetRssi();
static void SetRssiHistory(uint16_t idx, uint16_t rssi)
{
#ifdef ENABLE_SCAN_RANGES
if(scanInfo.measurementsCount > 128) {
uint8_t idx = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * scanInfo.i / 1000;
if(rssiHistory[idx] < rssi || isListening)
rssiHistory[idx] = rssi;
rssiHistory[(idx+1)%128] = 0;
uint8_t i = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * idx / 1000;
if(rssiHistory[i] < rssi || isListening)
rssiHistory[i] = rssi;
rssiHistory[(i+1)%128] = 0;
return;
}
#endif
rssiHistory[scanInfo.i] = rssi;
rssiHistory[idx] = rssi;
}

static void Measure()
{
uint16_t rssi = scanInfo.rssi = GetRssi();
SetRssiHistory(scanInfo.i, rssi);
}

// Update things by keypress
Expand Down Expand Up @@ -636,7 +641,8 @@ static void Blacklist() {
#ifdef ENABLE_SCAN_RANGES
blacklistFreqs[blacklistFreqsIdx++ % ARRAY_SIZE(blacklistFreqs)] = peak.i;
#endif
rssiHistory[peak.i] = RSSI_MAX_VALUE;

SetRssiHistory(peak.i, RSSI_MAX_VALUE);
ResetPeak();
ToggleRX(false);
ResetScanStats();
Expand Down

0 comments on commit 2cc60da

Please sign in to comment.