From fa91cf011bf6560a352cbb60306bc5d8d2229522 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Tue, 3 Mar 2026 02:19:30 +0100 Subject: [PATCH] [fix](trx-frontend): correct CW auto toggle requests Send boolean values for the CW auto toggle query and improve the CW tone picker waterfall contrast. Co-authored-by: Stan Grams Signed-off-by: Stan Grams --- .../trx-frontend-http/assets/web/plugins/cw.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/cw.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/cw.js index 2637cbf..2a547e7 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/cw.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/cw.js @@ -67,6 +67,7 @@ function drawCwTonePicker() { const fullLoHz = centerHz - sampleRate / 2; const tones = new Array(width).fill(0); let maxPower = 0; + let minPower = Number.POSITIVE_INFINITY; for (let x = 0; x < width; x += 1) { const frac = width <= 1 ? 0 : x / (width - 1); const toneHz = range.lowHz + frac * (range.highHz - range.lowHz); @@ -74,13 +75,14 @@ function drawCwTonePicker() { const power = Math.max(0, Number(bins[idx]) || 0); tones[x] = power; if (power > maxPower) maxPower = power; + if (power < minPower) minPower = power; } + const powerSpan = Math.max(1, maxPower - minPower); for (let x = 0; x < width; x += 1) { - const frac = width <= 1 ? 0 : x / (width - 1); - const level = maxPower > 0 ? tones[x] / maxPower : 0; + const level = Math.max(0, Math.min(1, (tones[x] - minPower) / powerSpan)); const hue = 200 - level * 155; - const light = 18 + level * 55; + const light = 14 + Math.pow(level, 0.75) * 58; ctx.fillStyle = `hsl(${hue} 85% ${light}%)`; ctx.fillRect(x, 0, 1, height); } @@ -109,7 +111,7 @@ if (cwAutoInput) { cwAutoInput.addEventListener("change", async () => { const enabled = cwAutoInput.checked; applyCwAutoUi(enabled); - try { await postPath(`/set_cw_auto?enabled=${enabled ? 1 : 0}`); } + try { await postPath(`/set_cw_auto?enabled=${enabled ? "true" : "false"}`); } catch (e) { console.error("CW auto toggle failed", e); } }); }