[feat](trx-rs): expose live sdr gain control
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -1257,6 +1257,13 @@ function render(update) {
|
||||
if (update.filter && typeof update.filter.bandwidth_hz === "number") {
|
||||
currentBandwidthHz = update.filter.bandwidth_hz;
|
||||
syncBandwidthInput(currentBandwidthHz);
|
||||
if (
|
||||
sdrGainEl
|
||||
&& typeof update.filter.sdr_gain_db === "number"
|
||||
&& document.activeElement !== sdrGainEl
|
||||
) {
|
||||
sdrGainEl.value = String(Math.round(update.filter.sdr_gain_db));
|
||||
}
|
||||
if (wfmDeemphasisEl && typeof update.filter.wfm_deemphasis_us === "number") {
|
||||
wfmDeemphasisEl.value = String(update.filter.wfm_deemphasis_us);
|
||||
}
|
||||
@@ -2567,6 +2574,8 @@ 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 sdrGainEl = document.getElementById("sdr-gain-db");
|
||||
const sdrGainSetBtn = document.getElementById("sdr-gain-set");
|
||||
const wfmStFlagEl = document.getElementById("wfm-st-flag");
|
||||
|
||||
// Hide audio row if audio is not configured on the server
|
||||
@@ -2611,6 +2620,23 @@ if (wfmDeemphasisEl) {
|
||||
postPath(`/set_wfm_deemphasis?us=${encodeURIComponent(wfmDeemphasisEl.value)}`).catch(() => {});
|
||||
});
|
||||
}
|
||||
function submitSdrGain() {
|
||||
if (!sdrGainEl) return;
|
||||
const parsed = Number.parseFloat(sdrGainEl.value);
|
||||
if (!Number.isFinite(parsed) || parsed < 0) return;
|
||||
postPath(`/set_sdr_gain?db=${encodeURIComponent(parsed)}`).catch(() => {});
|
||||
}
|
||||
if (sdrGainSetBtn) {
|
||||
sdrGainSetBtn.addEventListener("click", submitSdrGain);
|
||||
}
|
||||
if (sdrGainEl) {
|
||||
sdrGainEl.addEventListener("keydown", (ev) => {
|
||||
if (ev.key === "Enter") {
|
||||
ev.preventDefault();
|
||||
submitSdrGain();
|
||||
}
|
||||
});
|
||||
}
|
||||
function updateWfmControls() {
|
||||
if (!wfmControlsCol) return;
|
||||
const mode = (modeEl && modeEl.value ? modeEl.value : "").toUpperCase();
|
||||
|
||||
@@ -165,6 +165,10 @@
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@@ -186,6 +186,9 @@ input.status-input, select.status-input { width: 100%; padding: 0.45rem 0.5rem;
|
||||
width: auto;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
.wfm-control input.status-input {
|
||||
width: 5rem;
|
||||
}
|
||||
.wfm-control button.status-input {
|
||||
padding: 0.45rem 0.5rem;
|
||||
height: auto;
|
||||
|
||||
@@ -473,6 +473,19 @@ pub async fn set_fir_taps(
|
||||
send_command(&rig_tx, RigCommand::SetFirTaps(query.taps)).await
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct SdrGainQuery {
|
||||
pub db: f64,
|
||||
}
|
||||
|
||||
#[post("/set_sdr_gain")]
|
||||
pub async fn set_sdr_gain(
|
||||
query: web::Query<SdrGainQuery>,
|
||||
rig_tx: web::Data<mpsc::Sender<RigRequest>>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
send_command(&rig_tx, RigCommand::SetSdrGain(query.db)).await
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct WfmDeemphasisQuery {
|
||||
pub us: u32,
|
||||
@@ -710,6 +723,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
||||
.service(set_tx_limit)
|
||||
.service(set_bandwidth)
|
||||
.service(set_fir_taps)
|
||||
.service(set_sdr_gain)
|
||||
.service(set_wfm_deemphasis)
|
||||
.service(set_wfm_stereo)
|
||||
.service(toggle_aprs_decode)
|
||||
|
||||
Reference in New Issue
Block a user