2024-05-11 19:29:39 +02:00
|
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
use clap::Parser;
|
|
|
|
|
2024-05-18 11:11:15 +02:00
|
|
|
use servicepoint2::*;
|
2024-05-11 19:29:39 +02:00
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
|
|
|
struct Cli {
|
|
|
|
#[arg(short, long, default_value = "localhost:2342")]
|
|
|
|
destination: String,
|
|
|
|
#[arg(short, long = "duration-ms", default_value_t = 5000)]
|
|
|
|
time: u64,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2024-05-11 23:16:41 +02:00
|
|
|
env_logger::init();
|
2024-05-11 19:29:39 +02:00
|
|
|
let cli = Cli::parse();
|
2024-05-17 23:56:08 +02:00
|
|
|
|
|
|
|
let sleep_duration = Duration::max(
|
|
|
|
FRAME_PACING,
|
|
|
|
Duration::from_millis(cli.time / PIXEL_WIDTH as u64),
|
|
|
|
);
|
2024-05-11 19:29:39 +02:00
|
|
|
|
|
|
|
let connection = Connection::open(cli.destination).unwrap();
|
2024-05-16 21:32:33 +02:00
|
|
|
|
2024-05-11 23:28:08 +02:00
|
|
|
let mut enabled_pixels =
|
|
|
|
PixelGrid::new(PIXEL_WIDTH as usize, PIXEL_HEIGHT as usize);
|
2024-05-11 19:29:39 +02:00
|
|
|
enabled_pixels.fill(true);
|
|
|
|
|
|
|
|
for x_offset in 0..PIXEL_WIDTH as usize {
|
|
|
|
for y in 0..PIXEL_HEIGHT as usize {
|
|
|
|
enabled_pixels.set(x_offset % PIXEL_WIDTH as usize, y, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// this works because the pixel grid has max size
|
|
|
|
let pixel_data: Vec<u8> = enabled_pixels.clone().into();
|
2024-05-12 01:30:55 +02:00
|
|
|
let bit_vec = BitVec::from(&*pixel_data);
|
2024-05-11 19:29:39 +02:00
|
|
|
|
2024-05-11 23:28:08 +02:00
|
|
|
connection
|
2024-05-16 23:18:43 +02:00
|
|
|
.send(
|
|
|
|
Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma)
|
|
|
|
.into(),
|
|
|
|
)
|
2024-05-11 23:28:08 +02:00
|
|
|
.unwrap();
|
2024-05-11 19:29:39 +02:00
|
|
|
thread::sleep(sleep_duration);
|
|
|
|
}
|
|
|
|
}
|