// This file is part of librador-sys, Rust bindings to librador, the driver // for the EspoTek Labrador electronics lab board. // // Copyright 2021 Andrew Dona-Couch // // librador-sys is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // librador-sys is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . use librador_sys::{ librador_get_analog_data_sincelast, librador_init, librador_send_sin_wave, librador_set_device_mode, librador_set_oscilloscope_gain, librador_setup_usb, }; fn main() { println!("Initializing library..."); let res = librador_init(); assert_eq!(res, 0); println!("Setting up USB..."); let res = librador_setup_usb(); assert_eq!(res, 0); println!("Setting device mode to 0..."); let res = librador_set_device_mode(0); assert_eq!(res, 0); println!("Setting oscilloscope gain to 8..."); let res = librador_set_oscilloscope_gain(8.); assert_eq!(res, 0); println!("Setting signal out..."); let res = librador_send_sin_wave(1, 1., 1., 0.); assert_eq!(res, 0); println!("Waiting..."); std::thread::sleep(std::time::Duration::from_millis(500)); println!("Getting analog data..."); let data = librador_get_analog_data_sincelast(1, 0.4, 100., 0., 1 /* linear interpolation */); if data.is_null() { println!("Unable to get data!"); } else { unsafe { println!("Data: {:?}", *data) }; } for _ in 0..10 { println!("Waiting..."); std::thread::sleep(std::time::Duration::from_millis(10)); println!("Getting analog data..."); let data = librador_get_analog_data_sincelast(1, 0.4, 100., 0., 1 /* linear interpolation */); if data.is_null() { println!("Unable to get data!"); } else { unsafe { println!("Data: {:?}", *data) }; } } }