From 2d8dfb1a3dcae1c63cb89533c372f229485305d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Mar 2026 01:15:04 +0000 Subject: [PATCH] [feat](trx-frontend-http): add auto-squelch button to Audio panel Add an "Auto" button next to the SQL slider that sets the squelch threshold to the current noise floor (estimated from spectrum bins) plus a 6 dB margin. Uses the existing estimateNoiseFloorDb() heuristic. https://claude.ai/code/session_01TDQyrZiPKfWGATVWPsLmHT Signed-off-by: Claude --- .../trx-frontend-http/assets/web/app.js | 23 +++++++++++++++++++ .../trx-frontend-http/assets/web/index.html | 2 +- .../trx-frontend-http/assets/web/style.css | 9 ++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) 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 21231fd..36b2fd3 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 @@ -7669,6 +7669,29 @@ if (sdrSquelchEl) { }); } +const sdrSquelchAutoBtn = document.getElementById("sdr-squelch-auto"); +if (sdrSquelchAutoBtn) { + sdrSquelchAutoBtn.addEventListener("click", () => { + if (!sdrSquelchSupported) return; + 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 (sdrSquelchEl) { + sdrSquelchEl.value = String(pct); + updateSdrSquelchPctLabel(); + saveSetting("sdrSquelchPct", pct); + } + submitSdrSquelchPercent(pct); + }); +} + if (wfmAudioModeEl) { wfmAudioModeEl.value = loadSetting("wfmAudioMode", "stereo"); wfmAudioModeEl.addEventListener("change", () => { diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html index 621cf2f..e5bad22 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/index.html @@ -374,7 +374,7 @@ - +
diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css index 62ad286..2c4e90e 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/style.css @@ -1277,6 +1277,15 @@ small { color: var(--text-muted); } color: var(--text-muted); line-height: 1; } +.sql-auto-btn { + font-size: 0.68rem; + padding: 0 5px; + height: 1.2rem; + min-height: 0; + line-height: 1; + border-radius: 3px; + cursor: pointer; +} .vol-slider { -webkit-appearance: none; appearance: none;