mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-03 22:06:43 +00:00
+6
-6
@@ -12,23 +12,23 @@ impl Color {
|
|||||||
/// Get the color encoding of the color for one bit
|
/// Get the color encoding of the color for one bit
|
||||||
pub fn get_bit_value(&self) -> u8 {
|
pub fn get_bit_value(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Color::White => 0u8,
|
Color::White => 1u8,
|
||||||
Color::Black => 1u8,
|
Color::Black => 0u8,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets a full byte of black or white pixels
|
/// Gets a full byte of black or white pixels
|
||||||
pub fn get_byte_value(&self) -> u8 {
|
pub fn get_byte_value(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Color::White => 0x00,
|
Color::White => 0xff,
|
||||||
Color::Black => 0xff,
|
Color::Black => 0x00,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_u8(val: u8) -> Self {
|
fn from_u8(val: u8) -> Self {
|
||||||
match val {
|
match val {
|
||||||
1 => Color::Black,
|
0 => Color::Black,
|
||||||
0 => Color::White,
|
1 => Color::White,
|
||||||
e => panic!("DisplayColor only parses 0 and 1 (Black and White) and not `{}`", e),
|
e => panic!("DisplayColor only parses 0 and 1 (Black and White) and not `{}`", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -98,12 +98,10 @@ impl Drawing<Color> for DisplayEink42BlackWhite {
|
|||||||
|
|
||||||
match color {
|
match color {
|
||||||
Color::Black => {
|
Color::Black => {
|
||||||
//self.buffer[idx] &= !bit;
|
self.buffer[idx] &= !bit;
|
||||||
self.buffer[idx] |= bit;
|
|
||||||
}
|
}
|
||||||
Color::White => {
|
Color::White => {
|
||||||
//self.buffer[idx] |= bit;
|
self.buffer[idx] |= bit;
|
||||||
self.buffer[idx] &= !bit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user