forked from fafo/microscope-control
Easy experimenting with 3D printer or other CNC if open flexure is not available. Signed-off-by: Henner Zeller <h.zeller@acm.org>
71 lines
1.8 KiB
Rust
71 lines
1.8 KiB
Rust
use clap::{Parser, ValueEnum};
|
|
use std::{thread::sleep, time::Duration};
|
|
|
|
mod gcode_stage;
|
|
mod openflexure_stage;
|
|
|
|
mod stage_io;
|
|
use crate::stage_io::StageIO;
|
|
use crate::xy_stage::XYStage;
|
|
|
|
mod xy_stage;
|
|
|
|
#[derive(clap::Parser, Debug)]
|
|
#[command(version, about, long_about = None)]
|
|
struct CliArgs {
|
|
/// Interface to talk to movement stage
|
|
#[arg(long, default_value = "/dev/ttyACM0")]
|
|
stage_device: String,
|
|
|
|
/// Speed of the stage device (bps)
|
|
#[arg(long, default_value = "115200")]
|
|
tty_speed: u32,
|
|
|
|
#[arg(long, value_enum)]
|
|
backend: Backend,
|
|
}
|
|
|
|
// [derive(DebugCopy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
|
|
#[derive(Debug, Clone, ValueEnum)]
|
|
enum Backend {
|
|
/// OpenFlexure stage
|
|
OpenFlexure,
|
|
|
|
/// GCode stage
|
|
GCode,
|
|
}
|
|
|
|
fn main() {
|
|
let args = CliArgs::parse();
|
|
env_logger::init();
|
|
let stage_io = StageIO::new(&args.stage_device, args.tty_speed).unwrap();
|
|
let mut stage: Box<dyn XYStage> = match args.backend {
|
|
Backend::GCode => Box::new(gcode_stage::GCodeStage::new(stage_io).unwrap()),
|
|
Backend::OpenFlexure => {
|
|
Box::new(openflexure_stage::OpenFlexureStage::new(stage_io, 1.12).unwrap())
|
|
}
|
|
};
|
|
let origin = nalgebra::vector![0.0, 0.0, 0.0];
|
|
stage.move_absolute_cartesian(origin).unwrap();
|
|
sleep(Duration::from_secs(1));
|
|
let mut max_xy = stage.get_range();
|
|
max_xy[2] = 0.0;
|
|
stage.move_absolute_cartesian(max_xy).unwrap();
|
|
sleep(Duration::from_secs(5));
|
|
}
|
|
|
|
struct App {}
|
|
|
|
impl Default for App {
|
|
fn default() -> Self {
|
|
App {}
|
|
}
|
|
}
|
|
|
|
impl eframe::App for App {
|
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
|
egui::CentralPanel::default().show(ctx, |ui| {
|
|
ui.heading("My egui Application");
|
|
});
|
|
}
|
|
}
|