Browse Source

Clean up and simplify code

main
BuggStream 5 years ago
parent
commit
6129723c41
  1. 2
      src/epd1in54c/command.rs
  2. 2
      src/epd1in54c/graphics.rs
  3. 24
      src/epd1in54c/mod.rs

2
src/epd1in54c/command.rs

@ -1,4 +1,4 @@
//! SPI Commands for the Waveshare 1.54" red E-Ink Display
//! SPI Commands for the Waveshare 1.54" C red or yellow E-Ink Display
use crate::traits;
#[allow(dead_code)]

2
src/epd1in54c/graphics.rs

@ -3,7 +3,7 @@ use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
/// Full size buffer for use with the 1in54 EPD
/// Full size buffer for use with the 1in54c EPD
///
/// Can also be manually constructed and be used together with VarDisplay
pub struct Display1in54c {

24
src/epd1in54c/mod.rs

@ -16,15 +16,12 @@ pub const WIDTH: u32 = 152;
pub const HEIGHT: u32 = 152;
/// Default Background Color (white)
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8;
const IS_BUSY_LOW: bool = true;
const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8;
use crate::color::Color;
pub(crate) mod command;
use self::command::Command;
#[cfg(feature = "graphics")]
@ -100,10 +97,8 @@ where
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> {
self.wait_until_idle();
self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_1, black)?;
self.interface
.cmd(spi, Command::DATA_START_TRANSMISSION_1)?;
self.interface.data(spi, black)?;
Ok(())
}
@ -113,10 +108,8 @@ where
chromatic: &[u8],
) -> Result<(), SPI::Error> {
self.wait_until_idle();
self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_2, chromatic)?;
self.interface
.cmd(spi, Command::DATA_START_TRANSMISSION_2)?;
self.interface.data(spi, chromatic)?;
Ok(())
}
}
@ -189,8 +182,7 @@ where
// Clear the chromatic layer
let color = self.color.get_byte_value();
self.interface
.cmd(spi, Command::DATA_START_TRANSMISSION_2)?;
self.command(spi, Command::DATA_START_TRANSMISSION_2)?;
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
Ok(())
@ -228,13 +220,11 @@ where
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
// Clear the black
self.interface
.cmd(spi, Command::DATA_START_TRANSMISSION_1)?;
self.command(spi, Command::DATA_START_TRANSMISSION_1)?;
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
// Clear the red
self.interface
.cmd(spi, Command::DATA_START_TRANSMISSION_2)?;
// Clear the chromatic
self.command(spi, Command::DATA_START_TRANSMISSION_2)?;
self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?;
Ok(())

Loading…
Cancel
Save