[feat](trx-rs): add cw auto/manual controls

Co-authored-by: Codex <codex@openai.com>
Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
2026-02-09 20:50:31 +01:00
parent dfc0f220e8
commit 0daf9e27ae
15 changed files with 249 additions and 16 deletions
@@ -1,11 +1,53 @@
// --- CW (Morse) Decoder Plugin (server-side decode) ---
const cwStatusEl = document.getElementById("cw-status");
const cwOutputEl = document.getElementById("cw-output");
const cwAutoInput = document.getElementById("cw-auto");
const cwWpmInput = document.getElementById("cw-wpm");
const cwToneInput = document.getElementById("cw-tone");
const cwSignalIndicator = document.getElementById("cw-signal-indicator");
const CW_MAX_LINES = 200;
function applyCwAutoUi(enabled) {
if (cwAutoInput) cwAutoInput.checked = enabled;
if (cwWpmInput) {
cwWpmInput.disabled = enabled;
cwWpmInput.readOnly = enabled;
}
if (cwToneInput) {
cwToneInput.disabled = enabled;
cwToneInput.readOnly = enabled;
}
}
if (cwAutoInput) {
cwAutoInput.addEventListener("change", async () => {
const enabled = cwAutoInput.checked;
applyCwAutoUi(enabled);
try { await postPath(`/set_cw_auto?enabled=${enabled ? 1 : 0}`); }
catch (e) { console.error("CW auto toggle failed", e); }
});
}
if (cwWpmInput) {
cwWpmInput.addEventListener("change", async () => {
if (cwAutoInput && cwAutoInput.checked) return;
const wpm = Math.max(5, Math.min(40, Number(cwWpmInput.value)));
cwWpmInput.value = wpm;
try { await postPath(`/set_cw_wpm?wpm=${encodeURIComponent(wpm)}`); }
catch (e) { console.error("CW WPM set failed", e); }
});
}
if (cwToneInput) {
cwToneInput.addEventListener("change", async () => {
if (cwAutoInput && cwAutoInput.checked) return;
const tone = Math.max(300, Math.min(1200, Number(cwToneInput.value)));
cwToneInput.value = tone;
try { await postPath(`/set_cw_tone?tone_hz=${encodeURIComponent(tone)}`); }
catch (e) { console.error("CW tone set failed", e); }
});
}
document.getElementById("cw-clear-btn").addEventListener("click", async () => {
cwOutputEl.innerHTML = "";
try { await postPath("/clear_cw_decode"); } catch (e) { console.error("CW clear failed", e); }
@@ -34,6 +76,8 @@ window.onServerCw = function(evt) {
cwOutputEl.scrollTop = cwOutputEl.scrollHeight;
}
cwSignalIndicator.className = evt.signal_on ? "cw-signal-on" : "cw-signal-off";
cwWpmInput.value = evt.wpm;
cwToneInput.value = evt.tone_hz;
if (!cwAutoInput || cwAutoInput.checked) {
cwWpmInput.value = evt.wpm;
cwToneInput.value = evt.tone_hz;
}
};