[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:
@@ -7670,28 +7670,44 @@ if (sdrSquelchEl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sdrSquelchAutoBtn = document.getElementById("sdr-squelch-auto");
|
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) {
|
if (sdrSquelchAutoBtn) {
|
||||||
|
updateSdrSquelchAutoBtn();
|
||||||
sdrSquelchAutoBtn.addEventListener("click", () => {
|
sdrSquelchAutoBtn.addEventListener("click", () => {
|
||||||
if (!sdrSquelchSupported) return;
|
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;
|
const data = lastSpectrumData || window.lastSpectrumData;
|
||||||
if (data && Array.isArray(data.bins) && data.bins.length > 0) {
|
if (!data || !Array.isArray(data.bins) || data.bins.length === 0) return;
|
||||||
const noiseDb = estimateNoiseFloorDb(data.bins);
|
const noiseDb = estimateNoiseFloorDb(data.bins);
|
||||||
if (noiseDb != null && Number.isFinite(noiseDb)) {
|
if (noiseDb == null || !Number.isFinite(noiseDb)) return;
|
||||||
// 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,
|
);
|
||||||
);
|
sdrSquelchAutoActive = true;
|
||||||
}
|
updateSdrSquelchAutoBtn();
|
||||||
}
|
applySdrSquelchPct(pct);
|
||||||
if (sdrSquelchEl) {
|
|
||||||
sdrSquelchEl.value = String(pct);
|
|
||||||
updateSdrSquelchPctLabel();
|
|
||||||
saveSetting("sdrSquelchPct", pct);
|
|
||||||
}
|
|
||||||
submitSdrSquelchPercent(pct);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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><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">
|
||||||
<div id="audio-level-fill"></div>
|
<div id="audio-level-fill"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1286,6 +1286,10 @@ small { color: var(--text-muted); }
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
.sql-auto-btn.active {
|
||||||
|
background: var(--accent-green);
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
.vol-slider {
|
.vol-slider {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user