From 7edc8b7bfe1632badb7a653aaf7e9d035dd83739 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Mar 2026 06:22:09 +0000 Subject: [PATCH] [fix](trx-frontend-http): auto-squelch defaults to Off without spectrum data When no spectrum data is available, the Auto button now sets squelch to 0% (Off) instead of silently doing nothing. https://claude.ai/code/session_01TDQyrZiPKfWGATVWPsLmHT Signed-off-by: Claude --- .../trx-frontend-http/assets/web/app.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js index 36b2fd3..7b8e0f6 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js @@ -7673,16 +7673,19 @@ const sdrSquelchAutoBtn = document.getElementById("sdr-squelch-auto"); if (sdrSquelchAutoBtn) { sdrSquelchAutoBtn.addEventListener("click", () => { if (!sdrSquelchSupported) return; + let pct = 0; // default: Off const data = lastSpectrumData || window.lastSpectrumData; - if (!data || !Array.isArray(data.bins) || data.bins.length === 0) return; - const noiseDb = estimateNoiseFloorDb(data.bins); - if (noiseDb == null || !Number.isFinite(noiseDb)) return; - // Set threshold slightly above noise floor so squelch closes on noise - const thresholdDb = noiseDb + 6; - const clamped = Math.max(SDR_SQUELCH_MIN_DB, Math.min(SDR_SQUELCH_MAX_DB, thresholdDb)); - const pct = clampSdrSquelchPercent( - ((clamped - SDR_SQUELCH_MIN_DB) / (SDR_SQUELCH_MAX_DB - SDR_SQUELCH_MIN_DB)) * 100, - ); + if (data && Array.isArray(data.bins) && data.bins.length > 0) { + const noiseDb = estimateNoiseFloorDb(data.bins); + if (noiseDb != null && Number.isFinite(noiseDb)) { + // Set threshold slightly above noise floor so squelch closes on noise + const thresholdDb = noiseDb + 6; + const clamped = Math.max(SDR_SQUELCH_MIN_DB, Math.min(SDR_SQUELCH_MAX_DB, thresholdDb)); + pct = clampSdrSquelchPercent( + ((clamped - SDR_SQUELCH_MIN_DB) / (SDR_SQUELCH_MAX_DB - SDR_SQUELCH_MIN_DB)) * 100, + ); + } + } if (sdrSquelchEl) { sdrSquelchEl.value = String(pct); updateSdrSquelchPctLabel();