[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 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-27 06:44:04 +00:00
committed by Stan Grams
parent 7edc8b7bfe
commit 0e5410c0c5
3 changed files with 39 additions and 19 deletions
@@ -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);
});
}
@@ -374,7 +374,7 @@
<button id="tx-audio-btn" type="button">Transmit Audio</button>
<label class="vol-label">RX<input type="range" id="rx-vol" min="0" max="100" value="80" class="vol-slider" /><small class="vol-pct" id="rx-vol-pct">80%</small></label>
<label class="vol-label">TX<input type="range" id="tx-vol" min="0" max="100" value="80" class="vol-slider" /><small class="vol-pct" id="tx-vol-pct">80%</small></label>
<label class="vol-label" id="sdr-squelch-wrap" style="display:none;">SQL<input type="range" id="sdr-squelch" min="0" max="100" value="0" class="vol-slider" /><small class="vol-pct" id="sdr-squelch-pct">Open</small><button id="sdr-squelch-auto" type="button" class="sql-auto-btn" title="Set squelch to current noise level">Auto</button></label>
<label class="vol-label" id="sdr-squelch-wrap" style="display:none;">SQL<input type="range" id="sdr-squelch" min="0" max="100" value="0" class="vol-slider" /><small class="vol-pct" id="sdr-squelch-pct">Open</small><button id="sdr-squelch-auto" type="button" class="sql-auto-btn" title="Set squelch to current noise level">Off</button></label>
<div id="audio-level">
<div id="audio-level-fill"></div>
</div>
@@ -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;