From 9a4987787ed4f7390d83260b9e2de31d6732ca97 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Mon, 3 Jun 2024 22:49:00 +0200 Subject: [PATCH] add brightness tester --- .../examples/brightness_tester.rs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 crates/servicepoint/examples/brightness_tester.rs diff --git a/crates/servicepoint/examples/brightness_tester.rs b/crates/servicepoint/examples/brightness_tester.rs new file mode 100644 index 0000000..b1b1ac3 --- /dev/null +++ b/crates/servicepoint/examples/brightness_tester.rs @@ -0,0 +1,37 @@ +//! Show a brightness level test pattern on screen + +use clap::Parser; + +use servicepoint::Command::BitmapLinearWin; +use servicepoint::*; + +#[derive(Parser, Debug)] +struct Cli { + #[arg(short, long, default_value = "localhost:2342")] + destination: String, +} + +fn main() { + let cli = Cli::parse(); + let connection = Connection::open(cli.destination).unwrap(); + + let mut pixels = PixelGrid::max_sized(); + pixels.fill(true); + + connection + .send(BitmapLinearWin( + Origin(0, 0), + pixels, + CompressionCode::Uncompressed, + )) + .expect("send failed"); + + let mut brightnesses = ByteGrid::new(TILE_WIDTH, TILE_HEIGHT); + for (index, byte) in brightnesses.data_ref_mut().iter_mut().enumerate() { + *byte = (index % u8::MAX as usize) as u8; + } + + connection + .send(Command::CharBrightness(Origin(0, 0), brightnesses)) + .expect("send failed"); +}