mirror of
https://github.com/cccb/servicepoint.git
synced 2025-01-18 18:10:14 +01:00
use Origin::ZERO constant
This commit is contained in:
parent
97a994fca2
commit
cbadd85f07
|
@ -46,6 +46,6 @@ fn main() {
|
||||||
let cp437_grid = Cp437Grid::from(&grid);
|
let cp437_grid = Cp437Grid::from(&grid);
|
||||||
|
|
||||||
connection
|
connection
|
||||||
.send(Command::Cp437Data(Origin::new(0, 0), cp437_grid))
|
.send(Command::Cp437Data(Origin::ZERO, cp437_grid))
|
||||||
.expect("sending text failed");
|
.expect("sending text failed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn main() {
|
||||||
pixels.fill(true);
|
pixels.fill(true);
|
||||||
|
|
||||||
let command = Command::BitmapLinearWin(
|
let command = Command::BitmapLinearWin(
|
||||||
Origin::new(0, 0),
|
Origin::ZERO,
|
||||||
pixels,
|
pixels,
|
||||||
CompressionCode::Uncompressed,
|
CompressionCode::Uncompressed,
|
||||||
);
|
);
|
||||||
|
@ -33,6 +33,6 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
connection
|
connection
|
||||||
.send(Command::CharBrightness(Origin::new(0, 0), brightnesses))
|
.send(Command::CharBrightness(Origin::ZERO, brightnesses))
|
||||||
.expect("send failed");
|
.expect("send failed");
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn main() {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let command = Command::BitmapLinearWin(
|
let command = Command::BitmapLinearWin(
|
||||||
Origin::new(0, 0),
|
Origin::ZERO,
|
||||||
field.clone(),
|
field.clone(),
|
||||||
CompressionCode::Lzma,
|
CompressionCode::Lzma,
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let command = Command::BitmapLinearWin(
|
let command = Command::BitmapLinearWin(
|
||||||
Origin::new(0, 0),
|
Origin::ZERO,
|
||||||
pixels.clone(),
|
pixels.clone(),
|
||||||
CompressionCode::Lzma,
|
CompressionCode::Lzma,
|
||||||
);
|
);
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn main() {
|
||||||
filled_grid.fill(true);
|
filled_grid.fill(true);
|
||||||
|
|
||||||
let command = BitmapLinearWin(
|
let command = BitmapLinearWin(
|
||||||
Origin::new(0, 0),
|
Origin::ZERO,
|
||||||
filled_grid,
|
filled_grid,
|
||||||
CompressionCode::Lzma,
|
CompressionCode::Lzma,
|
||||||
);
|
);
|
||||||
|
|
|
@ -114,7 +114,7 @@ pub enum Command {
|
||||||
///
|
///
|
||||||
/// // create command to send pixels
|
/// // create command to send pixels
|
||||||
/// let command = Command::BitmapLinearWin(
|
/// let command = Command::BitmapLinearWin(
|
||||||
/// servicepoint::Origin::new(0, 0),
|
/// servicepoint::Origin::ZERO,
|
||||||
/// pixels,
|
/// pixels,
|
||||||
/// CompressionCode::Uncompressed
|
/// CompressionCode::Uncompressed
|
||||||
/// );
|
/// );
|
||||||
|
@ -588,7 +588,7 @@ mod tests {
|
||||||
compression,
|
compression,
|
||||||
));
|
));
|
||||||
round_trip(Command::BitmapLinearWin(
|
round_trip(Command::BitmapLinearWin(
|
||||||
Origin::new(0, 0),
|
Origin::ZERO,
|
||||||
Bitmap::max_sized(),
|
Bitmap::max_sized(),
|
||||||
compression,
|
compression,
|
||||||
));
|
));
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
/// # use servicepoint::{Command, CompressionCode, Origin, Bitmap};
|
/// # use servicepoint::{Command, CompressionCode, Origin, Bitmap};
|
||||||
/// // create command without payload compression
|
/// // create command without payload compression
|
||||||
/// # let pixels = Bitmap::max_sized();
|
/// # let pixels = Bitmap::max_sized();
|
||||||
/// _ = Command::BitmapLinearWin(Origin::new(0, 0), pixels, CompressionCode::Uncompressed);
|
/// _ = Command::BitmapLinearWin(Origin::ZERO, pixels, CompressionCode::Uncompressed);
|
||||||
///
|
///
|
||||||
/// // create command with payload compressed with lzma and appropriate header flags
|
/// // create command with payload compressed with lzma and appropriate header flags
|
||||||
/// # let pixels = Bitmap::max_sized();
|
/// # let pixels = Bitmap::max_sized();
|
||||||
/// _ = Command::BitmapLinearWin(Origin::new(0, 0), pixels, CompressionCode::Lzma);
|
/// _ = Command::BitmapLinearWin(Origin::ZERO, pixels, CompressionCode::Lzma);
|
||||||
/// ```
|
/// ```
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
//!
|
//!
|
||||||
//! // create command to send pixels
|
//! // create command to send pixels
|
||||||
//! let command = Command::BitmapLinearWin(
|
//! let command = Command::BitmapLinearWin(
|
||||||
//! servicepoint::Origin::new(0, 0),
|
//! servicepoint::Origin::ZERO,
|
||||||
//! pixels,
|
//! pixels,
|
||||||
//! CompressionCode::Uncompressed
|
//! CompressionCode::Uncompressed
|
||||||
//! );
|
//! );
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub struct Origin<Unit: DisplayUnit> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Unit: DisplayUnit> Origin<Unit> {
|
impl<Unit: DisplayUnit> Origin<Unit> {
|
||||||
/// Top-left. Equivalent to `Origin::new(0, 0)`.
|
/// Top-left. Equivalent to `Origin::ZERO`.
|
||||||
pub const ZERO: Self = Self {
|
pub const ZERO: Self = Self {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
|
|
Loading…
Reference in a new issue