From 48124d8a8f1b26e04c6a1a69fd5a1b7541a1d653 Mon Sep 17 00:00:00 2001 From: Niclas Hoyer Date: Sat, 11 Jan 2025 12:23:11 +0100 Subject: [PATCH] feat: add SET_GAIN_MODE message Fixes #35 --- src/main.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 76c221f..d3636d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -105,16 +105,28 @@ fn main() -> Result<(), Box> { info!("setting sample rate to {}", sample_rate); ctl.lock().unwrap().set_sample_rate(sample_rate).unwrap(); } - 0x05 => { - let ppm = i32::from_be_bytes((&buf[1..5]).try_into().unwrap()); - info!("setting ppm to {}", ppm); - ctl.lock().unwrap().set_ppm(ppm).unwrap(); + 0x03 => { + let gain_mode = i32::from_be_bytes((&buf[1..5]).try_into().unwrap()); + if gain_mode > 0 { + info!("manual tuner gain requested"); + info!("setting automatic gain control to on"); + ctl.lock().unwrap().enable_agc().unwrap(); + } else { + info!("manual tuner gain requested, disabling agc"); + info!("setting automatic gain control to off"); + ctl.lock().unwrap().disable_agc().unwrap(); + } } 0x04 => { let gain = i32::from_be_bytes((&buf[1..5]).try_into().unwrap()); info!("setting manual gain to {}", gain); ctl.lock().unwrap().set_tuner_gain(gain).unwrap(); } + 0x05 => { + let ppm = i32::from_be_bytes((&buf[1..5]).try_into().unwrap()); + info!("setting ppm to {}", ppm); + ctl.lock().unwrap().set_ppm(ppm).unwrap(); + } 0x08 => { let agc = u32::from_be_bytes((&buf[1..5]).try_into().unwrap()) == 1u32; if agc {