[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 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-27 06:22:09 +00:00
committed by Stan Grams
parent 2d8dfb1a3d
commit 7edc8b7bfe
@@ -7673,16 +7673,19 @@ const sdrSquelchAutoBtn = document.getElementById("sdr-squelch-auto");
if (sdrSquelchAutoBtn) { if (sdrSquelchAutoBtn) {
sdrSquelchAutoBtn.addEventListener("click", () => { sdrSquelchAutoBtn.addEventListener("click", () => {
if (!sdrSquelchSupported) return; if (!sdrSquelchSupported) return;
let pct = 0; // default: Off
const data = lastSpectrumData || window.lastSpectrumData; const data = lastSpectrumData || window.lastSpectrumData;
if (!data || !Array.isArray(data.bins) || data.bins.length === 0) return; if (data && Array.isArray(data.bins) && data.bins.length > 0) {
const noiseDb = estimateNoiseFloorDb(data.bins); const noiseDb = estimateNoiseFloorDb(data.bins);
if (noiseDb == null || !Number.isFinite(noiseDb)) return; if (noiseDb != null && Number.isFinite(noiseDb)) {
// Set threshold slightly above noise floor so squelch closes on noise // Set threshold slightly above noise floor so squelch closes on noise
const thresholdDb = noiseDb + 6; const thresholdDb = noiseDb + 6;
const clamped = Math.max(SDR_SQUELCH_MIN_DB, Math.min(SDR_SQUELCH_MAX_DB, thresholdDb)); const clamped = Math.max(SDR_SQUELCH_MIN_DB, Math.min(SDR_SQUELCH_MAX_DB, thresholdDb));
const pct = clampSdrSquelchPercent( pct = clampSdrSquelchPercent(
((clamped - SDR_SQUELCH_MIN_DB) / (SDR_SQUELCH_MAX_DB - SDR_SQUELCH_MIN_DB)) * 100, ((clamped - SDR_SQUELCH_MIN_DB) / (SDR_SQUELCH_MAX_DB - SDR_SQUELCH_MIN_DB)) * 100,
); );
}
}
if (sdrSquelchEl) { if (sdrSquelchEl) {
sdrSquelchEl.value = String(pct); sdrSquelchEl.value = String(pct);
updateSdrSquelchPctLabel(); updateSdrSquelchPctLabel();