simple-dmi: make decimation configurable

This commit is contained in:
Sebastien Bourdeauducq 2019-10-23 18:28:45 +08:00
parent 3200126fa8
commit 34cf0037ea
2 changed files with 6 additions and 3 deletions

View File

@ -7,5 +7,7 @@
"bit_meas": 1,
"refpll_ki": 4294967,
"refpll_kp": 85899345
"refpll_kp": 85899345,
"decimation": 200000
}

View File

@ -20,7 +20,8 @@ struct Config {
bit_ref: u8,
bit_meas: u8,
refpll_ki: i64,
refpll_kp: i64
refpll_kp: i64,
decimation: u32
}
fn read_config_from_file<P: AsRef<Path>>(path: P) -> Result<Config, Box<dyn Error>> {
@ -38,7 +39,7 @@ fn main() {
config.refpll_ki,
config.refpll_kp);
let mut tracker = noptica::Tracker::new();
let mut decimator = noptica::Decimator::new(200000);
let mut decimator = noptica::Decimator::new(config.decimation);
noptica::sample(&config.sample_command, |rising, _falling| {
refpll.tick(rising & (1 << config.bit_ref) != 0);
if rising & (1 << config.bit_meas) != 0 {