[feat](trx-client,trx-frontend-http): add default rig and hideable rf gain

Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-02-28 23:45:17 +01:00
parent 9453c90dac
commit 420e98de31
6 changed files with 44 additions and 5 deletions
@@ -1281,6 +1281,9 @@ function render(update) {
wfmStFlagEl.classList.toggle("wfm-st-flag-mono", !detected);
}
}
if (sdrGainControlsEl && typeof update.show_sdr_gain_control === "boolean") {
sdrGainControlsEl.style.display = update.show_sdr_gain_control ? "" : "none";
}
if (update.status && update.status.freq && typeof update.status.freq.hz === "number") {
applyLocalTunedFrequency(update.status.freq.hz, true);
}
@@ -2574,6 +2577,7 @@ const audioRow = document.getElementById("audio-row");
const wfmControlsCol = document.getElementById("wfm-controls-col");
const wfmDeemphasisEl = document.getElementById("wfm-deemphasis");
const wfmAudioModeEl = document.getElementById("wfm-audio-mode");
const sdrGainControlsEl = document.getElementById("sdr-gain-controls");
const sdrGainEl = document.getElementById("sdr-gain-db");
const sdrGainSetBtn = document.getElementById("sdr-gain-set");
const wfmStFlagEl = document.getElementById("wfm-st-flag");
@@ -165,10 +165,12 @@
<option value="mono">Mono</option>
</select>
</label>
<label class="wfm-control">RF Gain
<input id="sdr-gain-db" class="status-input" type="number" min="0" max="60" step="1" inputmode="decimal">
</label>
<button id="sdr-gain-set" type="button" class="status-input">Set</button>
<div class="inline" id="sdr-gain-controls">
<label class="wfm-control">RF Gain
<input id="sdr-gain-db" class="status-input" type="number" min="0" max="60" step="1" inputmode="decimal">
</label>
<button id="sdr-gain-set" type="button" class="status-input">Set</button>
</div>
<label class="wfm-control wfm-st-flag-wrap" aria-label="Stereo pilot status">
<span id="wfm-st-flag" class="wfm-st-flag wfm-st-flag-mono">MO</span>
</label>
@@ -45,6 +45,7 @@ pub async fn status_api(
active_rig_id_from_context(context.get_ref().as_ref()),
rig_ids_from_context(context.get_ref().as_ref()),
owner_callsign_from_context(context.get_ref().as_ref()),
show_sdr_gain_control_from_context(context.get_ref().as_ref()),
);
Ok(HttpResponse::Ok()
.insert_header((header::CONTENT_TYPE, "application/json"))
@@ -60,6 +61,7 @@ fn inject_frontend_meta(
active_rig_id: Option<String>,
rig_ids: Vec<String>,
owner_callsign: Option<String>,
show_sdr_gain_control: bool,
) -> String {
let mut value: serde_json::Value = match serde_json::from_str(json) {
Ok(v) => v,
@@ -84,6 +86,10 @@ fn inject_frontend_meta(
if let Some(owner) = owner_callsign {
map.insert("owner_callsign".to_string(), serde_json::json!(owner));
}
map.insert(
"show_sdr_gain_control".to_string(),
serde_json::json!(show_sdr_gain_control),
);
serde_json::to_string(&value).unwrap_or_else(|_| json.to_string())
}
@@ -118,6 +124,10 @@ fn owner_callsign_from_context(context: &FrontendRuntimeContext) -> Option<Strin
context.owner_callsign.clone()
}
fn show_sdr_gain_control_from_context(context: &FrontendRuntimeContext) -> bool {
context.http_show_sdr_gain_control
}
#[get("/events")]
pub async fn events(
state: web::Data<watch::Receiver<RigState>>,
@@ -140,6 +150,7 @@ pub async fn events(
active_rig_id_from_context(context.get_ref().as_ref()),
rig_ids_from_context(context.get_ref().as_ref()),
owner_callsign_from_context(context.get_ref().as_ref()),
show_sdr_gain_control_from_context(context.get_ref().as_ref()),
);
let initial_stream =
once(async move { Ok::<Bytes, Error>(Bytes::from(format!("data: {initial_json}\n\n"))) });
@@ -160,6 +171,7 @@ pub async fn events(
active_rig_id_from_context(context.as_ref()),
rig_ids_from_context(context.as_ref()),
owner_callsign_from_context(context.as_ref()),
show_sdr_gain_control_from_context(context.as_ref()),
);
Ok::<Bytes, Error>(Bytes::from(format!("data: {json}\n\n")))
})