[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 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-27 01:15:04 +00:00
committed by Stan Grams
parent 5d6b9a4d94
commit 2d8dfb1a3d
3 changed files with 33 additions and 1 deletions
@@ -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) { if (wfmAudioModeEl) {
wfmAudioModeEl.value = loadSetting("wfmAudioMode", "stereo"); wfmAudioModeEl.value = loadSetting("wfmAudioMode", "stereo");
wfmAudioModeEl.addEventListener("change", () => { wfmAudioModeEl.addEventListener("change", () => {
@@ -374,7 +374,7 @@
<button id="tx-audio-btn" type="button">Transmit Audio</button> <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">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">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></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>
<div id="audio-level"> <div id="audio-level">
<div id="audio-level-fill"></div> <div id="audio-level-fill"></div>
</div> </div>
@@ -1277,6 +1277,15 @@ small { color: var(--text-muted); }
color: var(--text-muted); color: var(--text-muted);
line-height: 1; 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 { .vol-slider {
-webkit-appearance: none; -webkit-appearance: none;
appearance: none; appearance: none;