mirror of
https://github.com/hubaldv/bioz-host-rs.git
synced 2025-12-06 05:11:17 +00:00
Created basic sinus output via postcard rpc.
This commit is contained in:
41
src/bin/main_gui.rs
Normal file
41
src/bin/main_gui.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
use bioz_host_rs::app::App;
|
||||
|
||||
use bioz_host_rs::communication::communicate_with_hardware;
|
||||
|
||||
use tokio::sync::mpsc::{self};
|
||||
|
||||
fn main() {
|
||||
|
||||
let rt = Runtime::new().expect("Unable to create Runtime");
|
||||
|
||||
// Enter the runtime so that `tokio::spawn` is available immediately.
|
||||
// let _enter = rt.enter();
|
||||
|
||||
let (run_impedancemeter_tx, run_impedancemeter_rx) = mpsc::channel::<u32>(2);
|
||||
|
||||
let app = App::new(run_impedancemeter_tx);
|
||||
let magnitude_clone = app.magnitude.clone();
|
||||
let phase_clone = app.phase.clone();
|
||||
let magnitude_series_clone = app.magnitude_series.clone();
|
||||
let phase_series_clone = app.phase_series.clone();
|
||||
|
||||
// Execute the runtime in its own thread.
|
||||
std::thread::spawn(move || {
|
||||
rt.block_on(communicate_with_hardware(
|
||||
run_impedancemeter_rx,
|
||||
magnitude_clone,
|
||||
phase_clone,
|
||||
magnitude_series_clone,
|
||||
phase_series_clone
|
||||
));
|
||||
});
|
||||
|
||||
// Run the GUI in the main thread.
|
||||
let _ = eframe::run_native(
|
||||
"Impedance Visualizer [egui + tokio] - Hubald Verzijl - 2025",
|
||||
eframe::NativeOptions::default(),
|
||||
Box::new(|_cc| Ok(Box::new(app))),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user