add new compression commands to BitmapLinearWin
This commit is contained in:
parent
6834bb084b
commit
da4df32878
8 changed files with 84 additions and 60 deletions
|
@ -4,7 +4,7 @@ use std::time::Duration;
|
|||
use clap::Parser;
|
||||
use rand::{distributions, Rng};
|
||||
|
||||
use servicepoint2::{Command, Connection, Origin, PixelGrid};
|
||||
use servicepoint2::{Command, CompressionCode, Connection, Origin, PixelGrid};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -23,7 +23,7 @@ fn main() {
|
|||
|
||||
loop {
|
||||
connection
|
||||
.send(Command::BitmapLinearWin(Origin::top_left(), field.clone()).into())
|
||||
.send(Command::BitmapLinearWin(Origin::top_left(), field.clone(), CompressionCode::Bzip2).into())
|
||||
.expect("could not send");
|
||||
thread::sleep(Duration::from_millis(30));
|
||||
field = iteration(field);
|
||||
|
@ -36,6 +36,7 @@ fn iteration(field: PixelGrid) -> PixelGrid {
|
|||
for y in 0..field.height {
|
||||
let old_state = field.get(x, y);
|
||||
let neighbors = count_neighbors(&field, x as i32, y as i32);
|
||||
|
||||
let new_state = matches!((old_state, neighbors), (true, 2) | (true, 3) | (false, 3));
|
||||
next.set(x, y, new_state);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
|||
|
||||
use clap::Parser;
|
||||
|
||||
use servicepoint2::{Command, Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
|
||||
use servicepoint2::{Command, CompressionCode, Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -24,7 +24,7 @@ fn main() {
|
|||
pixels.set((y + x_offset) % PIXEL_WIDTH as usize, y, true);
|
||||
}
|
||||
connection
|
||||
.send(Command::BitmapLinearWin(Origin::top_left(), pixels.clone()).into())
|
||||
.send(Command::BitmapLinearWin(Origin::top_left(), pixels.clone(), CompressionCode::Lzma).into())
|
||||
.unwrap();
|
||||
thread::sleep(Duration::from_millis(14));
|
||||
}
|
||||
|
|
|
@ -4,9 +4,7 @@ use clap::Parser;
|
|||
use rand::Rng;
|
||||
|
||||
use servicepoint2::Command::{BitmapLinearWin, Brightness, CharBrightness};
|
||||
use servicepoint2::{
|
||||
ByteGrid, Connection, Origin, PixelGrid, TILE_HEIGHT, TILE_WIDTH,
|
||||
};
|
||||
use servicepoint2::{ByteGrid, CompressionCode, Connection, Origin, PixelGrid, TILE_HEIGHT, TILE_WIDTH};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -30,7 +28,7 @@ fn main() {
|
|||
let mut filled_grid = PixelGrid::max_sized();
|
||||
filled_grid.fill(true);
|
||||
connection
|
||||
.send(BitmapLinearWin(Origin::top_left(), filled_grid).into())
|
||||
.send(BitmapLinearWin(Origin::top_left(), filled_grid, CompressionCode::Lzma).into())
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
|||
|
||||
use clap::Parser;
|
||||
|
||||
use servicepoint2::{BitVec, Command, CompressionCode, Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
|
||||
use servicepoint2::{BitVec, Command, CompressionCode, Connection, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid};
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Cli {
|
||||
|
@ -16,16 +16,10 @@ struct Cli {
|
|||
fn main() {
|
||||
env_logger::init();
|
||||
let cli = Cli::parse();
|
||||
let sleep_duration = Duration::from_millis(cli.time / PIXEL_WIDTH as u64);
|
||||
|
||||
let connection = Connection::open(cli.destination).unwrap();
|
||||
|
||||
let mut buf = PixelGrid::max_sized();
|
||||
buf.fill(true);
|
||||
connection.send(Command::BitmapLinearWin(Origin(0, 0), buf).into())
|
||||
.expect("send failed");
|
||||
|
||||
let sleep_duration = Duration::from_millis(cli.time / PIXEL_WIDTH as u64);
|
||||
|
||||
let mut enabled_pixels =
|
||||
PixelGrid::new(PIXEL_WIDTH as usize, PIXEL_HEIGHT as usize);
|
||||
enabled_pixels.fill(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue