mirror of
https://github.com/smittix/intercept.git
synced 2026-07-10 10:38:12 -07:00
Prefer progress data for scanner sweep
This commit is contained in:
@@ -598,49 +598,48 @@ function handleFrequencyUpdate(data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasProgress = data.progress !== undefined && Number.isFinite(data.progress);
|
||||||
const freqValue = (typeof data.frequency === 'number' && Number.isFinite(data.frequency))
|
const freqValue = (typeof data.frequency === 'number' && Number.isFinite(data.frequency))
|
||||||
? data.frequency
|
? data.frequency
|
||||||
: null;
|
: null;
|
||||||
|
const stepMhz = Math.max(0.001, (scannerStepKhz || 1) / 1000);
|
||||||
|
const freqTolerance = stepMhz * 2;
|
||||||
|
|
||||||
let progressValue = null;
|
let progressValue = null;
|
||||||
if (freqValue !== null) {
|
if (hasProgress) {
|
||||||
const stepMhz = Math.max(0.001, (scannerStepKhz || 1) / 1000);
|
progressValue = data.progress;
|
||||||
const freqTolerance = stepMhz * 2;
|
const clamped = Math.max(0, Math.min(1, progressValue));
|
||||||
|
if (lastScanProgress !== null && clamped < lastScanProgress) {
|
||||||
if (lastScanFreq !== null && (freqValue + freqTolerance) < lastScanFreq) {
|
const isCycleReset = lastScanProgress > 0.85 && clamped < 0.15;
|
||||||
const nearEnd = lastScanFreq >= (scannerEndFreq - freqTolerance * 2);
|
if (!isCycleReset) {
|
||||||
const nearStart = freqValue <= (scannerStartFreq + freqTolerance * 2);
|
return;
|
||||||
if (nearEnd && nearStart) {
|
}
|
||||||
scannerCycles++;
|
}
|
||||||
const cyclesEl = document.getElementById('mainScanCycles');
|
lastScanProgress = clamped;
|
||||||
if (cyclesEl) cyclesEl.textContent = scannerCycles;
|
} else if (freqValue !== null) {
|
||||||
lastScanFreq = null;
|
if (lastScanFreq !== null && (freqValue + freqTolerance) < lastScanFreq) {
|
||||||
lastScanProgress = null;
|
const nearEnd = lastScanFreq >= (scannerEndFreq - freqTolerance * 2);
|
||||||
if (scannerTotalSteps > 0) {
|
const nearStart = freqValue <= (scannerStartFreq + freqTolerance * 2);
|
||||||
scannerFreqsScanned = scannerCycles * scannerTotalSteps;
|
if (!nearEnd || !nearStart) {
|
||||||
const freqsEl = document.getElementById('mainFreqsScanned');
|
|
||||||
if (freqsEl) freqsEl.textContent = scannerFreqsScanned;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastScanFreq = freqValue;
|
lastScanFreq = freqValue;
|
||||||
progressValue = (freqValue - scannerStartFreq) / range;
|
progressValue = (freqValue - scannerStartFreq) / range;
|
||||||
} else if (data.progress !== undefined && Number.isFinite(data.progress)) {
|
lastScanProgress = Math.max(0, Math.min(1, progressValue));
|
||||||
progressValue = data.progress;
|
|
||||||
} else {
|
} else {
|
||||||
if (scannerMethod === 'power') {
|
if (scannerMethod === 'power') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
progressValue = 0;
|
progressValue = 0;
|
||||||
|
lastScanProgress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const clampedProgress = Math.max(0, Math.min(1, progressValue));
|
const clampedProgress = Math.max(0, Math.min(1, progressValue));
|
||||||
lastScanProgress = clampedProgress;
|
|
||||||
|
|
||||||
const displayFreq = (freqValue !== null)
|
const displayFreq = (freqValue !== null
|
||||||
|
&& freqValue >= (scannerStartFreq - freqTolerance)
|
||||||
|
&& freqValue <= (scannerEndFreq + freqTolerance))
|
||||||
? freqValue
|
? freqValue
|
||||||
: scannerStartFreq + (clampedProgress * range);
|
: scannerStartFreq + (clampedProgress * range);
|
||||||
const freqStr = displayFreq.toFixed(3);
|
const freqStr = displayFreq.toFixed(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user