Skip to main content

Epd2In9

Struct Epd2In9 

Source
pub struct Epd2In9<HW, STATE> { /* private fields */ }
Expand description

Controls v1 of the 2.9“ Waveshare e-paper display.

The display has a portrait orientation. This uses BinaryColor, where Off is black and On is white.

HW should implement ResetHw, BusyHw, DcHw, SpiHw, DelayHw, and ErrorHw.

Implementations§

Source§

impl<HW> Epd2In9<HW, StateUninitialized>
where HW: DcHw + ResetHw + BusyHw + DelayHw + ErrorHw + SpiHw, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Reset as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>,

Source

pub fn new(hw: HW) -> Self

Source§

impl<HW, STATE> Epd2In9<HW, STATE>
where HW: DcHw + ResetHw + BusyHw + DelayHw + ErrorHw + SpiHw, STATE: StateAwake, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Reset as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>,

Source

pub async fn init( self, spi: &mut HW::Spi, mode: RefreshMode, ) -> Result<Epd2In9<HW, StateReady>, HW::Error>

Initialise the display. This should be called before any other operations.

Source§

impl<HW, STATE> Epd2In9<HW, STATE>
where HW: DcHw + BusyHw + ErrorHw + SpiHw, STATE: StateAwake, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>,

Source

pub async fn set_border( &mut self, spi: &mut HW::Spi, color: BinaryColor, ) -> Result<(), HW::Error>

Sets the border to the specified colour. You need to call Displayable::update_display using RefreshMode::Full afterwards to apply this change.

Note: on my board, the white setting fades to grey fairly quickly. I have not found a way to avoid this.

Source

pub async fn send( &mut self, spi: &mut HW::Spi, command: Command, data: &[u8], ) -> Result<(), HW::Error>

Send the following command and data to the display. Waits until the display is no longer busy before sending.

Source§

impl<HW> Epd2In9<HW, StateReady>
where HW: DcHw + BusyHw + DelayHw + ErrorHw + SpiHw, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>,

Source

pub async fn set_refresh_mode( &mut self, spi: &mut HW::Spi, mode: RefreshMode, ) -> Result<(), HW::Error>

Sets the refresh mode.

Source

pub async fn set_window( &mut self, spi: &mut HW::Spi, shape: Rectangle, ) -> Result<(), HW::Error>

Sets the window to which the next image data will be written.

The x-axis only supports multiples of 8; values outside this result in a debug-mode panic, or potentially misaligned content when debug assertions are disabled.

Source

pub async fn set_cursor( &mut self, spi: &mut HW::Spi, position: Point, ) -> Result<(), HW::Error>

Sets the cursor position to write the next data to.

The x-axis only supports multiples of 8; values outside this will result in a panic in debug mode, or potentially misaligned content if debug assertions are disabled.

Trait Implementations§

Source§

impl<HW> DisplayPartial<1, 1, <HW as SpiHw>::Spi, <HW as ErrorHw>::Error> for Epd2In9<HW, StateReady>
where HW: DcHw + BusyHw + DelayHw + ErrorHw + SpiHw, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>,

Source§

async fn write_base_framebuffer( &mut self, spi: &mut HW::Spi, buf: &dyn BufferView<1, 1>, ) -> Result<(), HW::Error>

Writes buffer data into the old internal framebuffer. This can be useful either:

Source§

impl<HW> DisplaySimple<1, 1, <HW as SpiHw>::Spi, <HW as ErrorHw>::Error> for Epd2In9<HW, StateReady>
where HW: DcHw + BusyHw + DelayHw + ErrorHw + SpiHw, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>,

Source§

async fn display_framebuffer( &mut self, spi: &mut HW::Spi, buf: &dyn BufferView<1, 1>, ) -> Result<(), HW::Error>

Source§

async fn write_framebuffer( &mut self, spi: &mut HW::Spi, buf: &dyn BufferView<1, 1>, ) -> Result<(), HW::Error>

Writes the given buffer’s data into the main framebuffer to be displayed on the next call to Displayable::update_display.
Source§

impl<HW> Displayable<<HW as SpiHw>::Spi, <HW as ErrorHw>::Error> for Epd2In9<HW, StateReady>
where HW: DcHw + BusyHw + DelayHw + ErrorHw + SpiHw, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>,

Source§

async fn update_display(&mut self, spi: &mut HW::Spi) -> Result<(), HW::Error>

Updates (refreshes) the display based on what has been written to the framebuffer.
Source§

impl<HW, STATE> Reset<<HW as ErrorHw>::Error> for Epd2In9<HW, STATE>
where HW: ResetHw + DelayHw + ErrorHw, HW::Error: From<<HW::Reset as ErrorType>::Error>, STATE: StateAwake,

Source§

type DisplayOut = Epd2In9<HW, STATE>

Source§

async fn reset(self) -> Result<Self::DisplayOut, HW::Error>

Hardware resets the display.
Source§

impl<HW, W> Reset<<HW as ErrorHw>::Error> for Epd2In9<HW, StateAsleep<W>>
where HW: ResetHw + DelayHw + ErrorHw, HW::Error: From<<HW::Reset as ErrorType>::Error>, W: StateAwake,

Source§

type DisplayOut = Epd2In9<HW, W>

Source§

async fn reset(self) -> Result<Self::DisplayOut, HW::Error>

Hardware resets the display.
Source§

impl<HW, STATE> Sleep<<HW as SpiHw>::Spi, <HW as ErrorHw>::Error> for Epd2In9<HW, STATE>
where HW: DcHw + BusyHw + ErrorHw + SpiHw, HW::Error: From<<HW::Dc as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>, STATE: StateAwake,

Source§

type DisplayOut = Epd2In9<HW, StateAsleep<STATE>>

Source§

async fn sleep(self, spi: &mut HW::Spi) -> Result<Self::DisplayOut, HW::Error>

Puts the display to sleep.
Source§

impl<HW, W> Wake<<HW as SpiHw>::Spi, <HW as ErrorHw>::Error> for Epd2In9<HW, StateAsleep<W>>
where HW: ResetHw + BusyHw + DelayHw + ErrorHw + SpiHw, HW::Error: From<<HW::Reset as ErrorType>::Error> + From<<HW::Busy as ErrorType>::Error> + From<<HW::Spi as ErrorType>::Error>, W: StateAwake,

Source§

type DisplayOut = Epd2In9<HW, W>

Source§

async fn wake(self, _spi: &mut HW::Spi) -> Result<Self::DisplayOut, HW::Error>

Wakes and re-initialises the display (if necessary) if it’s asleep.

Auto Trait Implementations§

§

impl<HW, STATE> Freeze for Epd2In9<HW, STATE>
where HW: Freeze, STATE: Freeze,

§

impl<HW, STATE> RefUnwindSafe for Epd2In9<HW, STATE>
where HW: RefUnwindSafe, STATE: RefUnwindSafe,

§

impl<HW, STATE> Send for Epd2In9<HW, STATE>
where HW: Send, STATE: Send,

§

impl<HW, STATE> Sync for Epd2In9<HW, STATE>
where HW: Sync, STATE: Sync,

§

impl<HW, STATE> Unpin for Epd2In9<HW, STATE>
where HW: Unpin, STATE: Unpin,

§

impl<HW, STATE> UnsafeUnpin for Epd2In9<HW, STATE>
where HW: UnsafeUnpin, STATE: UnsafeUnpin,

§

impl<HW, STATE> UnwindSafe for Epd2In9<HW, STATE>
where HW: UnwindSafe, STATE: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.