[fix](trx-frontend-http): make bandplan strip visible for all rig types

Move the bandplan strip out of the SDR-only spectrum panel into the
always-visible signal-visual-block. Add bandplanComputeRange() that
derives a frequency range from the current tuned frequency and band
edges when no spectrum data is available (non-SDR rigs). Trigger
bandplan updates on frequency changes and from the overview draw loop.

https://claude.ai/code/session_01AyBktp6b8qFjchyyqwL7dv
Signed-off-by: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-29 21:57:20 +00:00
committed by Stan Grams
parent 72a496aadb
commit 9abd2b7748
2 changed files with 36 additions and 3 deletions
@@ -1468,6 +1468,7 @@ function drawHeaderSignalGraph() {
} }
positionRdsPsOverlay(); positionRdsPsOverlay();
drawSignalOverlay(); drawSignalOverlay();
updateBandplanStrip(bandplanComputeRange());
} }
function drawOverviewWaterfall(W, H, pal) { function drawOverviewWaterfall(W, H, pal) {
@@ -1989,6 +1990,9 @@ function applyLocalTunedFrequency(hz, forceDisplay = false) {
if (freqChanged && lastSpectrumData) { if (freqChanged && lastSpectrumData) {
scheduleSpectrumDraw(); scheduleSpectrumDraw();
} }
if (freqChanged && !lastSpectrumData) {
updateBandplanStrip(bandplanComputeRange());
}
positionRdsPsOverlay(); positionRdsPsOverlay();
} }
@@ -9908,7 +9912,7 @@ function drawSpectrum(data) {
updateSpectrumFreqAxis(range); updateSpectrumFreqAxis(range);
updateBookmarkAxis(range); updateBookmarkAxis(range);
updateBandplanStrip(range); updateBandplanStrip(range); // use precise spectrum range when available
drawSignalOverlay(); drawSignalOverlay();
} }
@@ -11267,6 +11271,35 @@ if (bandplanLabelsCheck) {
}); });
} }
function bandplanComputeRange() {
// When spectrum data is available (SDR), use the zoomed visible range
if (lastSpectrumData) {
return spectrumVisibleRange(lastSpectrumData);
}
// For non-SDR rigs, derive a range from the current tuned frequency.
// Find the band containing the frequency and show that full band.
const freq = lastFreqHz;
if (!freq || !Number.isFinite(freq)) return null;
// Check bandplan data for the current region to find the matching band
if (bandplanData && bandplanData[bandplanRegion]) {
const bands = bandplanData[bandplanRegion].bands;
for (const band of bands) {
if (freq >= band.low_hz && freq <= band.high_hz) {
const margin = (band.high_hz - band.low_hz) * 0.05;
return {
visLoHz: band.low_hz - margin,
visHiHz: band.high_hz + margin,
visSpanHz: (band.high_hz - band.low_hz) + 2 * margin,
};
}
}
}
// Fallback: show a 500 kHz window around the frequency
const span = 500000;
return { visLoHz: freq - span / 2, visHiHz: freq + span / 2, visSpanHz: span };
}
function bandplanVisibleSegments(region, loHz, hiHz) { function bandplanVisibleSegments(region, loHz, hiHz) {
if (!bandplanData || !bandplanData[region]) return []; if (!bandplanData || !bandplanData[region]) return [];
const bands = bandplanData[region].bands; const bands = bandplanData[region].bands;
@@ -11289,7 +11322,7 @@ function bandplanVisibleSegments(region, loHz, hiHz) {
function updateBandplanStrip(range) { function updateBandplanStrip(range) {
if (!bandplanStripEl) return; if (!bandplanStripEl) return;
if (bandplanRegion === "off" || !bandplanData) { if (!range || bandplanRegion === "off" || !bandplanData) {
if (bandplanStripEl.classList.contains("bp-visible")) { if (bandplanStripEl.classList.contains("bp-visible")) {
bandplanStripEl.classList.remove("bp-visible"); bandplanStripEl.classList.remove("bp-visible");
bandplanStripEl.innerHTML = ""; bandplanStripEl.innerHTML = "";
@@ -113,9 +113,9 @@
<div id="hf-aprs-bar-overlay" aria-live="polite" aria-label="Recent HF APRS frames"></div> <div id="hf-aprs-bar-overlay" aria-live="polite" aria-label="Recent HF APRS frames"></div>
<div id="cw-bar-overlay" aria-live="polite" aria-label="Recent CW decodes"></div> <div id="cw-bar-overlay" aria-live="polite" aria-label="Recent CW decodes"></div>
</div> </div>
<div id="spectrum-bandplan-strip" aria-label="Band plan allocations"></div>
<div id="spectrum-panel" style="display:none;"> <div id="spectrum-panel" style="display:none;">
<div class="spectrum-wrap"> <div class="spectrum-wrap">
<div id="spectrum-bandplan-strip" aria-label="Band plan allocations"></div>
<div id="spectrum-bookmark-axis"></div> <div id="spectrum-bookmark-axis"></div>
<div id="spectrum-bookmark-side-left" class="spectrum-bookmark-side spectrum-bookmark-side-left" aria-hidden="true"></div> <div id="spectrum-bookmark-side-left" class="spectrum-bookmark-side spectrum-bookmark-side-left" aria-hidden="true"></div>
<canvas id="spectrum-canvas"></canvas> <canvas id="spectrum-canvas"></canvas>