Browse Source

Cleanup of WaveshareInterface

-Removed update_and_display_frame
-removed update_and_display_partial_frame

-Renamed get_width and get_height to just width and height
embedded-hal-1.0
Christoph Groß 7 years ago
parent
commit
fa6bce5ee7
  1. 4
      src/epd1in54/mod.rs
  2. 21
      src/epd2in9/mod.rs
  3. 4
      src/epd4in2/mod.rs
  4. 31
      src/interface/mod.rs

4
src/epd1in54/mod.rs

@ -108,11 +108,11 @@ where
RST: OutputPin, RST: OutputPin,
Delay: DelayUs<u16> + DelayMs<u16>, Delay: DelayUs<u16> + DelayMs<u16>,
{ {
fn get_width(&self) -> u16 { fn width(&self) -> u16 {
WIDTH WIDTH
} }
fn get_height(&self) -> u16 { fn height(&self) -> u16 {
HEIGHT HEIGHT
} }

21
src/epd2in9/mod.rs

@ -113,11 +113,11 @@ where
RST: OutputPin, RST: OutputPin,
Delay: DelayUs<u16> + DelayMs<u16>, Delay: DelayUs<u16> + DelayMs<u16>,
{ {
fn get_width(&self) -> u16 { fn width(&self) -> u16 {
WIDTH WIDTH
} }
fn get_height(&self) -> u16 { fn height(&self) -> u16 {
HEIGHT HEIGHT
} }
@ -187,23 +187,6 @@ where
self.interface.command(Command::NOP) self.interface.command(Command::NOP)
} }
fn update_and_display_frame(&mut self, buffer: &[u8]) -> Result<(), ERR> {
self.update_frame(buffer)?;
self.display_frame()
}
fn update_and_display_partial_frame(
&mut self,
buffer: &[u8],
x: u16,
y: u16,
width: u16,
height: u16,
) -> Result<(), ERR> {
self.update_partial_frame(buffer, x, y, width, height)?;
self.display_frame()
}
fn clear_frame(&mut self) -> Result<(), ERR> { fn clear_frame(&mut self) -> Result<(), ERR> {
self.use_full_frame()?; self.use_full_frame()?;

4
src/epd4in2/mod.rs

@ -291,11 +291,11 @@ where
&self.color &self.color
} }
fn get_width(&self) -> u16 { fn width(&self) -> u16 {
WIDTH WIDTH
} }
fn get_height(&self) -> u16 { fn height(&self) -> u16 {
HEIGHT HEIGHT
} }

31
src/interface/mod.rs

@ -9,12 +9,14 @@ use color::Color;
/// Interface for the physical connection between display and the controlling device /// Interface for the physical connection between display and the controlling device
pub(crate) mod connection_interface; pub(crate) mod connection_interface;
/// All commands need to have this trait which gives the address of the command /// All commands need to have this trait which gives the address of the command
/// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode) /// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode)
pub(crate) trait Command { pub(crate) trait Command {
fn address(self) -> u8; fn address(self) -> u8;
} }
//TODO: add LUT trait with set_fast_lut and set_manual_lut and set_normal_lut or sth like that? //TODO: add LUT trait with set_fast_lut and set_manual_lut and set_normal_lut or sth like that?
// for partial updates // for partial updates
trait LUTSupport<ERR> { trait LUTSupport<ERR> {
@ -23,6 +25,7 @@ trait LUTSupport<ERR> {
fn set_lut_manual(&mut self, data: &[u8]) -> Result<(), ERR>; fn set_lut_manual(&mut self, data: &[u8]) -> Result<(), ERR>;
} }
pub(crate) trait InternalWiAdditions<SPI, CS, BUSY, DC, RST, Delay, ERR> pub(crate) trait InternalWiAdditions<SPI, CS, BUSY, DC, RST, Delay, ERR>
where where
SPI: Write<u8>, SPI: Write<u8>,
@ -66,26 +69,6 @@ where
where where
Self: Sized; Self: Sized;
// TODO: add this abstraction function
/// Loads a full image on the EPD and displays it
fn update_and_display_frame(&mut self, buffer: &[u8]) -> Result<(), ERR> {
self.update_frame(buffer)?;
self.display_frame()
}
/// Loads a partial image on the EPD and displays it
fn update_and_display_partial_frame(
&mut self,
buffer: &[u8],
x: u16,
y: u16,
width: u16,
height: u16,
) -> Result<(), ERR> {
self.update_partial_frame(buffer, x, y, width, height)?;
self.display_frame()
}
/// Let the device enter deep-sleep mode to save power. /// Let the device enter deep-sleep mode to save power.
/// ///
/// The deep sleep mode returns to standby with a hardware reset. /// The deep sleep mode returns to standby with a hardware reset.
@ -104,19 +87,17 @@ where
fn background_color(&self) -> &Color; fn background_color(&self) -> &Color;
/// Get the width of the display /// Get the width of the display
fn get_width(&self) -> u16; fn width(&self) -> u16;
/// Get the height of the display /// Get the height of the display
fn get_height(&self) -> u16; fn height(&self) -> u16;
/// Abstraction of setting the delay for simpler calls /// Abstraction of setting the delay for simpler calls
/// ///
/// maximum delay ~65 seconds (u16:max in ms) /// maximum delay ~65 seconds (u16:max in ms)
fn delay_ms(&mut self, delay: u16); fn delay_ms(&mut self, delay: u16);
// void DisplayFrame(const unsigned char* frame_buffer); /// Transmit a full frame to the SRAM of the EPD
/// Transmit a full frame to the SRAM of the DPD
///
fn update_frame(&mut self, buffer: &[u8]) -> Result<(), ERR>; fn update_frame(&mut self, buffer: &[u8]) -> Result<(), ERR>;
/// Transmits partial data to the SRAM of the EPD /// Transmits partial data to the SRAM of the EPD

Loading…
Cancel
Save