forked from fafo/microscope-control
Implement simple GCode stage.
Easy experimenting with 3D printer or other CNC if open flexure is not available. Signed-off-by: Henner Zeller <h.zeller@acm.org>
This commit is contained in:
parent
4f620ad899
commit
ad9b1cb8c2
4 changed files with 72 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use clap::Parser;
|
||||
use clap::{Parser, ValueEnum};
|
||||
use std::{thread::sleep, time::Duration};
|
||||
|
||||
mod gcode_stage;
|
||||
mod openflexure_stage;
|
||||
|
||||
mod stage_io;
|
||||
|
|
@ -19,19 +20,37 @@ struct CliArgs {
|
|||
/// 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 s = openflexure_stage::OpenFlexureStage::new(stage_io, 1.12).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];
|
||||
s.move_absolute_cartesian(origin).unwrap();
|
||||
stage.move_absolute_cartesian(origin).unwrap();
|
||||
sleep(Duration::from_secs(1));
|
||||
let mut max_xy = s.get_range();
|
||||
let mut max_xy = stage.get_range();
|
||||
max_xy[2] = 0.0;
|
||||
s.move_absolute_cartesian(max_xy).unwrap();
|
||||
stage.move_absolute_cartesian(max_xy).unwrap();
|
||||
sleep(Duration::from_secs(5));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue