servicepoint/examples/moving_line.rs
Vinzenz Schroeter 1cf37413e6
All checks were successful
Rust / build (pull_request) Successful in 2m15s
implement From<X> for XCommand
2025-03-25 22:20:44 +01:00

32 lines
858 B
Rust

//! A simple example for how to send pixel data to the display.
use clap::Parser;
use servicepoint::{
Bitmap, BitmapCommand, Connection, Grid, UdpConnection, FRAME_PACING,
PIXEL_HEIGHT, PIXEL_WIDTH,
};
use std::thread;
#[derive(Parser, Debug)]
struct Cli {
#[arg(short, long, default_value = "localhost:2342")]
destination: String,
}
fn main() {
let connection = UdpConnection::open(Cli::parse().destination)
.expect("could not connect to display");
let mut bitmap = Bitmap::max_sized();
for x_offset in 0..usize::MAX {
bitmap.fill(false);
for y in 0..PIXEL_HEIGHT {
bitmap.set((y + x_offset) % PIXEL_WIDTH, y, true);
}
let command = BitmapCommand::from(bitmap.clone());
connection.send(command).expect("send failed");
thread::sleep(FRAME_PACING);
}
}