mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 10:00:14 +01:00
more From for Cp437Grid and BitVec
This commit is contained in:
parent
eb7496b27d
commit
ab16f57292
|
@ -42,10 +42,10 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let text = cli.text.join("\n");
|
let text = cli.text.join("\n");
|
||||||
let grid = CharGrid::from(&*text);
|
let grid = CharGrid::from(text);
|
||||||
let cp437_grid = Cp437Grid::from(&grid);
|
let grid = Cp437Grid::from(grid);
|
||||||
|
|
||||||
connection
|
connection
|
||||||
.send(Command::Cp437Data(Origin::ZERO, cp437_grid))
|
.send(Command::Cp437Data(Origin::ZERO, grid))
|
||||||
.expect("sending text failed");
|
.expect("sending text failed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,8 @@ fn main() {
|
||||||
enabled_pixels.set(x_offset % PIXEL_WIDTH, y, false);
|
enabled_pixels.set(x_offset % PIXEL_WIDTH, y, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this works because the pixel grid has max size
|
|
||||||
let pixel_data: Vec<u8> = enabled_pixels.clone().into();
|
|
||||||
let bit_vec = BitVec::from_vec(pixel_data);
|
|
||||||
|
|
||||||
connection
|
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");
|
.expect("could not send command to display");
|
||||||
thread::sleep(sleep_duration);
|
thread::sleep(sleep_duration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,12 @@ impl From<Bitmap> for Vec<u8> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Bitmap> for BitVec {
|
||||||
|
fn from(value: Bitmap) -> Self {
|
||||||
|
value.bit_vec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct IterRows<'t> {
|
pub struct IterRows<'t> {
|
||||||
bitmap: &'t Bitmap,
|
bitmap: &'t Bitmap,
|
||||||
row: usize,
|
row: usize,
|
||||||
|
|
|
@ -141,6 +141,12 @@ mod feature_cp437 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<CharGrid> for Cp437Grid {
|
||||||
|
fn from(value: CharGrid) -> Self {
|
||||||
|
Cp437Grid::from(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<&str> for CharGrid {
|
impl From<&str> for CharGrid {
|
||||||
fn from(value: &str) -> Self {
|
fn from(value: &str) -> Self {
|
||||||
let value = value.replace("\r\n", "\n");
|
let value = value.replace("\r\n", "\n");
|
||||||
|
@ -166,6 +172,12 @@ mod feature_cp437 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<String> for CharGrid {
|
||||||
|
fn from(value: String) -> Self {
|
||||||
|
CharGrid::from(&value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<&CharGrid> for String {
|
impl From<&CharGrid> for String {
|
||||||
fn from(value: &CharGrid) -> Self {
|
fn from(value: &CharGrid) -> Self {
|
||||||
value
|
value
|
||||||
|
|
Loading…
Reference in a new issue