mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
add brightness tester
This commit is contained in:
parent
59301a5fc5
commit
9a4987787e
37
crates/servicepoint/examples/brightness_tester.rs
Normal file
37
crates/servicepoint/examples/brightness_tester.rs
Normal file
|
@ -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");
|
||||
}
|
Loading…
Reference in a new issue