[fix](trx-frontend): expose spectrum state to CW picker
Mirror live spectrum, tuned frequency, and bandwidth state onto the window object so the CW tone picker can render from current spectrum data. Co-authored-by: Stan Grams <sjg@haxx.space> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -355,6 +355,7 @@ function syncTopBarAccess() {
|
|||||||
|
|
||||||
let overviewDrawPending = false;
|
let overviewDrawPending = false;
|
||||||
let lastSpectrumData = null;
|
let lastSpectrumData = null;
|
||||||
|
window.lastSpectrumData = null;
|
||||||
let lastControl;
|
let lastControl;
|
||||||
let lastTxEn = null;
|
let lastTxEn = null;
|
||||||
let lastHasTx = true;
|
let lastHasTx = true;
|
||||||
@@ -368,6 +369,7 @@ let sigMeasureAccumMs = 0;
|
|||||||
let sigMeasureWeighted = 0;
|
let sigMeasureWeighted = 0;
|
||||||
let sigMeasurePeak = null;
|
let sigMeasurePeak = null;
|
||||||
let lastFreqHz = null;
|
let lastFreqHz = null;
|
||||||
|
window.lastFreqHz = null;
|
||||||
let centerFreqDirty = false;
|
let centerFreqDirty = false;
|
||||||
let jogUnit = loadSetting("jogUnit", 1000); // base unit: 1, 1000, 1000000
|
let jogUnit = loadSetting("jogUnit", 1000); // base unit: 1, 1000, 1000000
|
||||||
let jogMult = loadSetting("jogMult", 1); // divisor: 1, 10, 100
|
let jogMult = loadSetting("jogMult", 1); // divisor: 1, 10, 100
|
||||||
@@ -1185,6 +1187,7 @@ function applyLocalTunedFrequency(hz, forceDisplay = false) {
|
|||||||
resetWfmStereoIndicator();
|
resetWfmStereoIndicator();
|
||||||
}
|
}
|
||||||
lastFreqHz = hz;
|
lastFreqHz = hz;
|
||||||
|
window.lastFreqHz = lastFreqHz;
|
||||||
updateDocumentTitle(lastSpectrumData?.rds ?? null);
|
updateDocumentTitle(lastSpectrumData?.rds ?? null);
|
||||||
refreshWavelengthDisplay(lastFreqHz);
|
refreshWavelengthDisplay(lastFreqHz);
|
||||||
if (forceDisplay) {
|
if (forceDisplay) {
|
||||||
@@ -2085,6 +2088,7 @@ function render(update) {
|
|||||||
// Sync filter state (SDR backends only)
|
// Sync filter state (SDR backends only)
|
||||||
if (update.filter && typeof update.filter.bandwidth_hz === "number") {
|
if (update.filter && typeof update.filter.bandwidth_hz === "number") {
|
||||||
currentBandwidthHz = update.filter.bandwidth_hz;
|
currentBandwidthHz = update.filter.bandwidth_hz;
|
||||||
|
window.currentBandwidthHz = currentBandwidthHz;
|
||||||
syncBandwidthInput(currentBandwidthHz);
|
syncBandwidthInput(currentBandwidthHz);
|
||||||
if (window.refreshCwTonePicker) {
|
if (window.refreshCwTonePicker) {
|
||||||
window.refreshCwTonePicker();
|
window.refreshCwTonePicker();
|
||||||
@@ -2879,6 +2883,7 @@ function formatBwLabel(hz) {
|
|||||||
|
|
||||||
// Current receive bandwidth (Hz) — updated by server sync and BW drag.
|
// Current receive bandwidth (Hz) — updated by server sync and BW drag.
|
||||||
let currentBandwidthHz = 3_000;
|
let currentBandwidthHz = 3_000;
|
||||||
|
window.currentBandwidthHz = currentBandwidthHz;
|
||||||
const spectrumBwInput = document.getElementById("spectrum-bw-input");
|
const spectrumBwInput = document.getElementById("spectrum-bw-input");
|
||||||
const spectrumBwSetBtn = document.getElementById("spectrum-bw-set-btn");
|
const spectrumBwSetBtn = document.getElementById("spectrum-bw-set-btn");
|
||||||
const spectrumBwAutoBtn = document.getElementById("spectrum-bw-auto-btn");
|
const spectrumBwAutoBtn = document.getElementById("spectrum-bw-auto-btn");
|
||||||
@@ -2904,6 +2909,7 @@ function syncBandwidthInput(hz) {
|
|||||||
async function applyBwDefaultForMode(mode, sendToServer) {
|
async function applyBwDefaultForMode(mode, sendToServer) {
|
||||||
const [def] = mwDefaultsForMode(mode);
|
const [def] = mwDefaultsForMode(mode);
|
||||||
currentBandwidthHz = def;
|
currentBandwidthHz = def;
|
||||||
|
window.currentBandwidthHz = currentBandwidthHz;
|
||||||
syncBandwidthInput(def);
|
syncBandwidthInput(def);
|
||||||
if (sendToServer) {
|
if (sendToServer) {
|
||||||
try { await postPath(`/set_bandwidth?hz=${def}`); } catch (_) {}
|
try { await postPath(`/set_bandwidth?hz=${def}`); } catch (_) {}
|
||||||
@@ -2921,6 +2927,7 @@ async function applyBandwidthFromInput() {
|
|||||||
}
|
}
|
||||||
const clamped = Math.max(minBw, Math.min(maxBw, next));
|
const clamped = Math.max(minBw, Math.min(maxBw, next));
|
||||||
currentBandwidthHz = clamped;
|
currentBandwidthHz = clamped;
|
||||||
|
window.currentBandwidthHz = currentBandwidthHz;
|
||||||
syncBandwidthInput(clamped);
|
syncBandwidthInput(clamped);
|
||||||
if (lastSpectrumData) scheduleSpectrumDraw();
|
if (lastSpectrumData) scheduleSpectrumDraw();
|
||||||
try {
|
try {
|
||||||
@@ -2994,6 +3001,7 @@ async function applyAutoBandwidth() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentBandwidthHz = estimated;
|
currentBandwidthHz = estimated;
|
||||||
|
window.currentBandwidthHz = currentBandwidthHz;
|
||||||
syncBandwidthInput(estimated);
|
syncBandwidthInput(estimated);
|
||||||
if (lastSpectrumData) scheduleSpectrumDraw();
|
if (lastSpectrumData) scheduleSpectrumDraw();
|
||||||
try {
|
try {
|
||||||
@@ -4964,6 +4972,7 @@ function startSpectrumStreaming() {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
lastSpectrumData = JSON.parse(evt.data);
|
lastSpectrumData = JSON.parse(evt.data);
|
||||||
|
window.lastSpectrumData = lastSpectrumData;
|
||||||
lastSpectrumRenderData = buildSpectrumRenderData(lastSpectrumData);
|
lastSpectrumRenderData = buildSpectrumRenderData(lastSpectrumData);
|
||||||
settlePendingSpectrumFrameWaiters(lastSpectrumData);
|
settlePendingSpectrumFrameWaiters(lastSpectrumData);
|
||||||
pushSpectrumPeakHoldFrame(lastSpectrumRenderData);
|
pushSpectrumPeakHoldFrame(lastSpectrumRenderData);
|
||||||
@@ -5832,6 +5841,7 @@ if (spectrumCanvas) {
|
|||||||
const [, minBw, maxBw] = mwDefaultsForMode(modeEl ? modeEl.value : "USB");
|
const [, minBw, maxBw] = mwDefaultsForMode(modeEl ? modeEl.value : "USB");
|
||||||
newBw = Math.round(Math.max(minBw, Math.min(maxBw, newBw)));
|
newBw = Math.round(Math.max(minBw, Math.min(maxBw, newBw)));
|
||||||
currentBandwidthHz = newBw;
|
currentBandwidthHz = newBw;
|
||||||
|
window.currentBandwidthHz = currentBandwidthHz;
|
||||||
syncBandwidthInput(newBw);
|
syncBandwidthInput(newBw);
|
||||||
scheduleSpectrumDraw();
|
scheduleSpectrumDraw();
|
||||||
scheduleOverviewDraw();
|
scheduleOverviewDraw();
|
||||||
|
|||||||
Reference in New Issue
Block a user