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-18 12:34:28 +00:00
|
|
|
pub mod api;
|
2024-06-29 16:55:37 +00:00
|
|
|
|
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,
|
2024-07-17 18:17:18 +00:00
|
|
|
/// Start the HTTP server
|
2024-06-29 16:55:37 +00:00
|
|
|
Serve,
|
|
|
|
}
|
|
|
|
|
2024-07-18 12:34:28 +00:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> anyhow::Result<()> {
|
2024-06-29 16:55:37 +00:00
|
|
|
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);
|
2024-07-17 17:37:43 +00:00
|
|
|
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
|
|
|
}
|