[feat](trx-frontend-http): refine SDR bandwidth control
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -1561,10 +1561,22 @@ function formatBwLabel(hz) {
|
||||
// Current receive bandwidth (Hz) — updated by server sync and BW drag.
|
||||
let currentBandwidthHz = 3_000;
|
||||
const spectrumBwInput = document.getElementById("spectrum-bw-input");
|
||||
const spectrumBwSetBtn = document.getElementById("spectrum-bw-set-btn");
|
||||
|
||||
function formatBandwidthInputKhz(hz) {
|
||||
const khz = hz / 1000;
|
||||
if (Math.abs(Math.round(khz) - khz) < 0.0001) return String(Math.round(khz));
|
||||
if (Math.abs(Math.round(khz * 10) - khz * 10) < 0.0001) return khz.toFixed(1);
|
||||
return khz.toFixed(2);
|
||||
}
|
||||
|
||||
function syncBandwidthInput(hz) {
|
||||
if (!spectrumBwInput || !Number.isFinite(hz) || hz <= 0) return;
|
||||
spectrumBwInput.value = String(Math.round(hz));
|
||||
const [, minBw, maxBw, stepBw] = mwDefaultsForMode(modeEl ? modeEl.value : "USB");
|
||||
spectrumBwInput.min = String(minBw / 1000);
|
||||
spectrumBwInput.max = String(maxBw / 1000);
|
||||
spectrumBwInput.step = String(stepBw / 1000);
|
||||
spectrumBwInput.value = formatBandwidthInputKhz(hz);
|
||||
}
|
||||
|
||||
// Apply mode-specific BW default and optionally push to server.
|
||||
@@ -1580,7 +1592,8 @@ async function applyBwDefaultForMode(mode, sendToServer) {
|
||||
async function applyBandwidthFromInput() {
|
||||
if (!spectrumBwInput) return;
|
||||
const [, minBw, maxBw] = mwDefaultsForMode(modeEl ? modeEl.value : "USB");
|
||||
const next = Math.round(Number(spectrumBwInput.value));
|
||||
const nextKhz = Number(spectrumBwInput.value);
|
||||
const next = Math.round(nextKhz * 1000);
|
||||
if (!Number.isFinite(next) || next <= 0) {
|
||||
syncBandwidthInput(currentBandwidthHz);
|
||||
return;
|
||||
@@ -1593,7 +1606,6 @@ async function applyBandwidthFromInput() {
|
||||
}
|
||||
|
||||
if (spectrumBwInput) {
|
||||
spectrumBwInput.addEventListener("change", () => { applyBandwidthFromInput(); });
|
||||
spectrumBwInput.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
@@ -1601,6 +1613,9 @@ if (spectrumBwInput) {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (spectrumBwSetBtn) {
|
||||
spectrumBwSetBtn.addEventListener("click", () => { applyBandwidthFromInput(); });
|
||||
}
|
||||
|
||||
// --- Tab navigation ---
|
||||
document.querySelector(".tab-bar").addEventListener("click", (e) => {
|
||||
|
||||
@@ -65,7 +65,10 @@
|
||||
<div id="spectrum-freq-axis"></div>
|
||||
</div>
|
||||
<div id="spectrum-controls">
|
||||
<label id="spectrum-bw-label">Bandwidth <input type="number" id="spectrum-bw-input" value="" step="100" min="1" /> Hz</label>
|
||||
<div id="spectrum-bw-row">
|
||||
<label id="spectrum-bw-label">Bandwidth <input type="number" id="spectrum-bw-input" value="" step="0.1" min="0.1" /> kHz</label>
|
||||
<button id="spectrum-bw-set-btn" type="button">Set</button>
|
||||
</div>
|
||||
<div id="spectrum-level-row">
|
||||
<label id="spectrum-floor-label">Floor <input type="number" id="spectrum-floor-input" value="-100" step="5" /> dB</label>
|
||||
<button id="spectrum-auto-btn" type="button">Auto</button>
|
||||
|
||||
@@ -653,17 +653,21 @@ button:focus-visible, input:focus-visible, select:focus-visible {
|
||||
font-size: 0.78rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
#spectrum-bw-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
#spectrum-bw-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
font-size: 0.78rem;
|
||||
color: var(--accent-yellow);
|
||||
font-weight: 600;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
min-width: 0;
|
||||
}
|
||||
#spectrum-bw-input {
|
||||
width: 5.25rem;
|
||||
width: 4.5rem;
|
||||
padding: 1px 4px;
|
||||
font-size: 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
@@ -673,6 +677,12 @@ button:focus-visible, input:focus-visible, select:focus-visible {
|
||||
text-align: right;
|
||||
height: 1.5rem;
|
||||
}
|
||||
#spectrum-bw-set-btn {
|
||||
height: 1.5rem;
|
||||
min-height: 0;
|
||||
padding: 0 8px;
|
||||
font-size: 0.73rem;
|
||||
}
|
||||
#spectrum-level-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user