From 993a7d2626c0443df1bcb711f06a3326ef7a8e02 Mon Sep 17 00:00:00 2001 From: Smittix Date: Wed, 4 Feb 2026 12:30:13 +0000 Subject: [PATCH] Stabilize sweep display and lower SNR default --- routes/listening_post.py | 8 ++++---- static/js/modes/listening-post.js | 12 +++++++----- templates/index.html | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/routes/listening_post.py b/routes/listening_post.py index 0575434..40df5ce 100644 --- a/routes/listening_post.py +++ b/routes/listening_post.py @@ -64,7 +64,7 @@ scanner_config = { 'bias_t': False, # Bias-T power for external LNA 'sdr_type': 'rtlsdr', # SDR type: rtlsdr, hackrf, airspy, limesdr, sdrplay 'scan_method': 'power', # power (rtl_power) or classic (rtl_fm hop) - 'snr_threshold': 12, + 'snr_threshold': 8, } # Activity log @@ -529,7 +529,7 @@ def scanner_loop_power(): if total_bins <= 0: time.sleep(0.2) continue - global_index = 0 + segment_offset = 0 for sweep_start, sweep_end, sweep_bin, bin_values in segments: # Noise floor (median) @@ -550,7 +550,7 @@ def scanner_loop_power(): snr = val - noise_floor level = int(max(0, snr) * 100) threshold = int(snr_threshold * 100) - progress = min(1.0, global_index / max(1, total_bins - 1)) + progress = min(1.0, (segment_offset + idx) / max(1, total_bins - 1)) try: scanner_queue.put_nowait({ 'type': 'scan_update', @@ -562,7 +562,7 @@ def scanner_loop_power(): }) except queue.Full: pass - global_index += emit_stride + segment_offset += len(bin_values) # Detect peaks (clusters above threshold) peaks = [] diff --git a/static/js/modes/listening-post.js b/static/js/modes/listening-post.js index bc2cb96..be5e3d9 100644 --- a/static/js/modes/listening-post.js +++ b/static/js/modes/listening-post.js @@ -28,7 +28,7 @@ let audioQueue = []; let isWebSocketAudio = false; let audioFetchController = null; let audioUnlockRequested = false; -let scannerSnrThreshold = 12; +let scannerSnrThreshold = 8; // Visualizer state let visualizerContext = null; @@ -570,7 +570,11 @@ function handleScannerEvent(data) { } function handleFrequencyUpdate(data) { - const freqStr = data.frequency.toFixed(3); + const progressValue = (data.progress !== undefined) + ? data.progress + : ((data.frequency - scannerStartFreq) / (scannerEndFreq - scannerStartFreq)); + const displayFreq = scannerStartFreq + (progressValue * (scannerEndFreq - scannerStartFreq)); + const freqStr = displayFreq.toFixed(3); const currentFreq = document.getElementById('scannerCurrentFreq'); if (currentFreq) currentFreq.textContent = freqStr + ' MHz'; @@ -579,9 +583,7 @@ function handleFrequencyUpdate(data) { if (mainFreq) mainFreq.textContent = freqStr; // Update progress bar - const progress = (data.progress !== undefined) - ? (data.progress * 100) - : ((data.frequency - scannerStartFreq) / (scannerEndFreq - scannerStartFreq)) * 100; + const progress = Math.max(0, Math.min(100, progressValue * 100)); const progressBar = document.getElementById('scannerProgressBar'); if (progressBar) progressBar.style.width = Math.max(0, Math.min(100, progress)) + '%'; diff --git a/templates/index.html b/templates/index.html index 8d99eff..31d9acc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1073,10 +1073,10 @@
SNR THRESH - 12 + style="font-size: 8px; color: var(--text-muted); min-width: 26px; text-align: right;">8