pi-frame-server/src/main.rs

51 lines
1.2 KiB
Rust
Raw Normal View History

2024-07-16 23:55:59 +00:00
#[cfg(feature = "eink")]
2024-07-02 15:57:29 +00:00
pub mod display;
2024-06-29 16:55:37 +00:00
pub mod imageproc;
2024-07-16 23:55:59 +00:00
use crate::display::Wrapper;
2024-07-17 18:27:31 +00:00
use crate::imageproc::{DiffusionMatrix, Ditherer, EInkImage, ErrorDiffusionDither};
2024-07-02 15:57:29 +00:00
use clap::{Parser, Subcommand};
use image::RgbImage;
/// Display images over
2024-06-29 16:55:37 +00:00
#[derive(Debug, Parser)]
#[command(version, about)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Debug, Subcommand)]
enum Command {
/// Load a single image
2024-07-02 15:57:29 +00:00
Show,
2024-07-17 05:24:11 +00:00
/// Display a test pattern
Test,
/// Start the HTTP server
2024-06-29 16:55:37 +00:00
Serve,
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
println!("CLI {cli:?}");
2024-07-17 05:24:11 +00:00
if matches!(cli.command, Command::Show) {
2024-07-02 15:57:29 +00:00
let img: RgbImage = image::io::Reader::open("myimage.png")?.decode()?.into();
2024-07-16 23:55:59 +00:00
let mut display = Wrapper::new()?;
2024-07-02 15:57:29 +00:00
2024-07-17 18:27:31 +00:00
let mut eink_buf = EInkImage::new(800, 480);
let dither = ErrorDiffusionDither::new(DiffusionMatrix::Atkinson);
2024-07-02 15:57:29 +00:00
dither.dither(&img, &mut eink_buf);
let raw_buf = eink_buf.into_display_buffer();
display.display(&raw_buf)?;
2024-07-17 05:24:11 +00:00
}
if matches!(cli.command, Command::Test) {
let mut display = Wrapper::new()?;
display.test()?;
}
2024-06-29 16:55:37 +00:00
Ok(())
2024-06-24 13:29:59 +00:00
}