diff --git a/Cargo.toml b/Cargo.toml index cda21d5..8eb7cfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,4 @@ version = "0.10.0" missing-docs = "warn" [workspace.dependencies] -thiserror = "1.0.69" +thiserror = "1.0.69" \ No newline at end of file diff --git a/crates/servicepoint/examples/announce.rs b/crates/servicepoint/examples/announce.rs index af78a54..66227a4 100644 --- a/crates/servicepoint/examples/announce.rs +++ b/crates/servicepoint/examples/announce.rs @@ -42,10 +42,10 @@ fn main() { } let text = cli.text.join("\n"); - let grid = CharGrid::from(&*text); - let cp437_grid = Cp437Grid::from(&grid); + let grid = CharGrid::from(text); + let grid = Cp437Grid::from(grid); connection - .send(Command::Cp437Data(Origin::ZERO, cp437_grid)) + .send(Command::Cp437Data(Origin::ZERO, grid)) .expect("sending text failed"); } diff --git a/crates/servicepoint/examples/wiping_clear.rs b/crates/servicepoint/examples/wiping_clear.rs index a3bf04a..6fd202e 100644 --- a/crates/servicepoint/examples/wiping_clear.rs +++ b/crates/servicepoint/examples/wiping_clear.rs @@ -33,12 +33,8 @@ fn main() { enabled_pixels.set(x_offset % PIXEL_WIDTH, y, false); } - // this works because the pixel grid has max size - let pixel_data: Vec = enabled_pixels.clone().into(); - let bit_vec = BitVec::from_vec(pixel_data); - connection - .send(Command::BitmapLinearAnd(0, bit_vec, CompressionCode::Lzma)) + .send(Command::BitmapLinearWin(Origin::ZERO, enabled_pixels.clone(), CompressionCode::Lzma)) .expect("could not send command to display"); thread::sleep(sleep_duration); } diff --git a/crates/servicepoint/src/bitmap.rs b/crates/servicepoint/src/bitmap.rs index 697a0d5..3d23706 100644 --- a/crates/servicepoint/src/bitmap.rs +++ b/crates/servicepoint/src/bitmap.rs @@ -175,6 +175,12 @@ impl From for Vec { } } +impl From for BitVec { + fn from(value: Bitmap) -> Self { + value.bit_vec + } +} + pub struct IterRows<'t> { bitmap: &'t Bitmap, row: usize, diff --git a/crates/servicepoint/src/cp437.rs b/crates/servicepoint/src/cp437.rs index 7b4d3af..1c1fba9 100644 --- a/crates/servicepoint/src/cp437.rs +++ b/crates/servicepoint/src/cp437.rs @@ -141,6 +141,12 @@ mod feature_cp437 { } } + impl From for Cp437Grid { + fn from(value: CharGrid) -> Self { + Cp437Grid::from(&value) + } + } + impl From<&str> for CharGrid { fn from(value: &str) -> Self { let value = value.replace("\r\n", "\n"); @@ -166,6 +172,12 @@ mod feature_cp437 { } } + impl From for CharGrid { + fn from(value: String) -> Self { + CharGrid::from(&value) + } + } + impl From<&CharGrid> for String { fn from(value: &CharGrid) -> Self { value