From 0e5410c0c5883fd469e3e1a3d01eb29c38f408e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Mar 2026 06:44:04 +0000 Subject: [PATCH] [feat](trx-frontend-http): make auto-squelch a toggle, default to Off The Auto button now toggles between Off and Auto states. Default is Off. First click sets squelch to noise floor + 6 dB; second click resets to Open (0%). Button shows active state with green highlight when engaged. https://claude.ai/code/session_01TDQyrZiPKfWGATVWPsLmHT Signed-off-by: Claude --- .../trx-frontend-http/assets/web/app.js | 52 ++++++++++++------- .../trx-frontend-http/assets/web/index.html | 2 +- .../trx-frontend-http/assets/web/style.css | 4 ++ 3 files changed, 39 insertions(+), 19 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 7b8e0f6..11f30ce 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 @@ -7670,28 +7670,44 @@ if (sdrSquelchEl) { } const sdrSquelchAutoBtn = document.getElementById("sdr-squelch-auto"); +let sdrSquelchAutoActive = false; +function updateSdrSquelchAutoBtn() { + if (!sdrSquelchAutoBtn) return; + sdrSquelchAutoBtn.textContent = sdrSquelchAutoActive ? "Auto" : "Off"; + sdrSquelchAutoBtn.classList.toggle("active", sdrSquelchAutoActive); +} +function applySdrSquelchPct(pct) { + if (sdrSquelchEl) { + sdrSquelchEl.value = String(pct); + updateSdrSquelchPctLabel(); + saveSetting("sdrSquelchPct", pct); + } + submitSdrSquelchPercent(pct); +} if (sdrSquelchAutoBtn) { + updateSdrSquelchAutoBtn(); sdrSquelchAutoBtn.addEventListener("click", () => { if (!sdrSquelchSupported) return; - let pct = 0; // default: Off + if (sdrSquelchAutoActive) { + // Toggle off: set squelch to 0% (Open) + sdrSquelchAutoActive = false; + updateSdrSquelchAutoBtn(); + applySdrSquelchPct(0); + return; + } + // Toggle on: set squelch to noise floor + 6 dB const data = lastSpectrumData || window.lastSpectrumData; - 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(); - saveSetting("sdrSquelchPct", pct); - } - submitSdrSquelchPercent(pct); + if (!data || !Array.isArray(data.bins) || data.bins.length === 0) return; + const noiseDb = estimateNoiseFloorDb(data.bins); + if (noiseDb == null || !Number.isFinite(noiseDb)) return; + 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, + ); + sdrSquelchAutoActive = true; + updateSdrSquelchAutoBtn(); + applySdrSquelchPct(pct); }); } 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 e5bad22..de2fdbf 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 2c4e90e..4105008 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 @@ -1286,6 +1286,10 @@ small { color: var(--text-muted); } border-radius: 3px; cursor: pointer; } +.sql-auto-btn.active { + background: var(--accent-green); + color: #000; +} .vol-slider { -webkit-appearance: none; appearance: none;