pub trait Epd<HW>where
HW: EpdHw,{
type RefreshMode;
type Buffer: DrawTarget;
Show 13 methods
// Required methods
fn new_buffer(&self) -> Self::Buffer;
fn width(&self) -> u32;
fn height(&self) -> u32;
async fn init(
&mut self,
spi: &mut HW::Spi,
mode: Self::RefreshMode,
) -> Result<(), HW::Error>;
async fn set_refresh_mode(
&mut self,
spi: &mut HW::Spi,
mode: Self::RefreshMode,
) -> Result<(), HW::Error>;
async fn reset(&mut self) -> Result<(), HW::Error>;
async fn sleep(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>;
async fn wake(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>;
async fn display_buffer(
&mut self,
spi: &mut HW::Spi,
buffer: &Self::Buffer,
) -> Result<(), HW::Error>;
async fn set_window(
&mut self,
spi: &mut HW::Spi,
shape: Rectangle,
) -> Result<(), HW::Error>;
async fn set_cursor(
&mut self,
spi: &mut HW::Spi,
position: Point,
) -> Result<(), <HW as EpdHw>::Error>;
async fn write_image(
&mut self,
spi: &mut HW::Spi,
image: &[u8],
) -> Result<(), HW::Error>;
async fn update_display(
&mut self,
spi: &mut HW::Spi,
) -> Result<(), HW::Error>;
}Required Associated Types§
type RefreshMode
type Buffer: DrawTarget
Required Methods§
Sourcefn new_buffer(&self) -> Self::Buffer
fn new_buffer(&self) -> Self::Buffer
Creates a buffer for use with this display.
fn width(&self) -> u32
fn height(&self) -> u32
Sourceasync fn init(
&mut self,
spi: &mut HW::Spi,
mode: Self::RefreshMode,
) -> Result<(), HW::Error>
async fn init( &mut self, spi: &mut HW::Spi, mode: Self::RefreshMode, ) -> Result<(), HW::Error>
Initialise the display. This must be called before any other operations.
Sourceasync fn set_refresh_mode(
&mut self,
spi: &mut HW::Spi,
mode: Self::RefreshMode,
) -> Result<(), HW::Error>
async fn set_refresh_mode( &mut self, spi: &mut HW::Spi, mode: Self::RefreshMode, ) -> Result<(), HW::Error>
Sets the refresh mode for the display.
Sourceasync fn sleep(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>
async fn sleep(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>
Puts the display to sleep.
Sourceasync fn wake(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>
async fn wake(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>
Wakes and re-initialises the display (if necessary) if it’s asleep.
Sourceasync fn display_buffer(
&mut self,
spi: &mut HW::Spi,
buffer: &Self::Buffer,
) -> Result<(), HW::Error>
async fn display_buffer( &mut self, spi: &mut HW::Spi, buffer: &Self::Buffer, ) -> Result<(), HW::Error>
Writes the buffer’s data to the display and displays it.
Sourceasync fn set_window(
&mut self,
spi: &mut HW::Spi,
shape: Rectangle,
) -> Result<(), HW::Error>
async fn set_window( &mut self, spi: &mut HW::Spi, shape: Rectangle, ) -> Result<(), HW::Error>
Sets the window to write to during a call to Epd::write_image. This can enable partial writes to a subsection of the display.
Sourceasync fn set_cursor(
&mut self,
spi: &mut HW::Spi,
position: Point,
) -> Result<(), <HW as EpdHw>::Error>
async fn set_cursor( &mut self, spi: &mut HW::Spi, position: Point, ) -> Result<(), <HW as EpdHw>::Error>
Sets the cursor position for where the next byte of image data will be written.
Sourceasync fn write_image(
&mut self,
spi: &mut HW::Spi,
image: &[u8],
) -> Result<(), HW::Error>
async fn write_image( &mut self, spi: &mut HW::Spi, image: &[u8], ) -> Result<(), HW::Error>
Writes raw image data, starting at the current cursor position and auto-incrementing x and y within the current window. By default, x should increment first, then y (data is written in rows).
Sourceasync fn update_display(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>
async fn update_display(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>
Updates (refreshes) the display based on what has been written to RAM. Note that this can be stateful. For example, on the Epd2in9 display, there are two RAM buffers. Calling this function swaps the active buffer. Consider this scenario:
- Epd::write_image is used to turn the RAM all white.
- Epd::update_display is called, which refreshes the display to be all white.
- Epd::write_image is used to turn the RAM all black.
- Epd::update_display is called, which refreshes the display to be all black.
- Epd::update_display is called again, which refreshes the display to be all white again.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.