Open source laser wavemeter with NO expensive optics and NO machining
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

extern crate num_traits;
extern crate serde_derive;
extern crate serde_json;
use serde_derive::Deserialize;
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
mod noptica;
#[derive(Deserialize, Debug)]
struct Config {
sample_command: String,
sample_rate: f64,
freq_min: f64,
freq_max: f64,
bit_ref: u8,
refpll_ki: i64,
refpll_kl: i64
fn read_config_from_file<P: AsRef<Path>>(path: P) -> Result<Config, Box<Error>> {
let file = File::open(path)?;
let reader = BufReader::new(file);
let u = serde_json::from_reader(reader)?;
fn main() {
let config = read_config_from_file("config.json").unwrap();
let mut refpll = noptica::Dpll::new(
noptica::Dpll::frequency_to_ftw(config.freq_min, config.sample_rate),
noptica::Dpll::frequency_to_ftw(config.freq_max, config.sample_rate),
noptica::sample(&config.sample_command, |rising, _falling| {
refpll.tick(rising & (1 << config.bit_ref) != 0);
// println!("{}", refpll.get_phase_unwrapped());