use liveplot::{channel_plot, run_liveplot, LivePlotConfig, PlotPoint};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
fn main() -> eframe::Result<()> {
let (sink, rx) = channel_plot();
let trace = sink.create_trace("signal", Some("Test Sine"));
std::thread::spawn(move || {
const FS_HZ: f64 = 1000.0; const F_HZ: f64 = 3.0; let dt = Duration::from_millis(1);
let mut n: u64 = 0;
loop {
let t = n as f64 / FS_HZ;
let val = (2.0 * std::f64::consts::PI * F_HZ * t).sin();
let t_s = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_secs_f64())
.unwrap_or(0.0);
let _ = sink.send_point(&trace, PlotPoint { x: t_s, y: val });
n = n.wrapping_add(1);
std::thread::sleep(dt);
}
});
run_liveplot(rx, LivePlotConfig::default())
}