Run cargo fmt

This commit is contained in:
Henner Zeller 2026-03-08 20:38:48 +01:00
parent a6077d755e
commit 2da9567679
2 changed files with 22 additions and 23 deletions

View file

@ -1,15 +1,15 @@
use clap::{Parser, ValueEnum};
use std::path::PathBuf;
use image::RgbImage;
use std::path::PathBuf;
mod camera;
mod gcode_stage;
mod openflexure_stage;
mod camera;
mod stage_io;
use crate::camera::Camera;
use crate::stage_io::StageIO;
use crate::xy_stage::XYStage;
use crate::camera::Camera;
mod xy_stage;
@ -33,7 +33,7 @@ struct CliArgs {
camera_index: u32,
/// Directory all captured images are stored.
#[arg(long, value_name="out-dir")]
#[arg(long, value_name = "out-dir")]
output_directory: PathBuf,
}
@ -47,10 +47,8 @@ enum Backend {
GCode,
}
fn store_image(number: u32, pos: nalgebra::Vector3<f64>, dir: &PathBuf,
img: &RgbImage) {
let img_file =
&dir.join(format!("img-{:05}-{:0},{:0}.png", number, pos[0], pos[1]));
fn store_image(number: u32, pos: nalgebra::Vector3<f64>, dir: &PathBuf, img: &RgbImage) {
let img_file = &dir.join(format!("img-{:05}-{:0},{:0}.png", number, pos[0], pos[1]));
img.save(img_file).unwrap();
}
@ -60,14 +58,14 @@ fn main() {
let args = CliArgs::parse();
if !args.output_directory.is_dir() {
panic!("--out-dir needs to be an existing directory");
panic!("--out-dir needs to be an existing directory");
}
let origin = nalgebra::vector![0.0, 0.0, 0.0];
// Picture source
let mut cam = Camera::new(args.camera_index).unwrap();
cam.capture().unwrap(); // Warm up camera.
cam.capture().unwrap(); // Warm up camera.
// Movement
let stage_io = StageIO::new(&args.stage_device, args.tty_speed).unwrap();
@ -85,8 +83,10 @@ fn main() {
max_xy[2] = 0.0;
for n in 0..10 {
stage.move_absolute_cartesian(max_xy * n as f64 / 10.0).unwrap();
store_image(n, origin, &args.output_directory, &cam.capture().unwrap());
stage
.move_absolute_cartesian(max_xy * n as f64 / 10.0)
.unwrap();
store_image(n, origin, &args.output_directory, &cam.capture().unwrap());
}
}