Skip to main content

St7789

Struct St7789 

Source
pub struct St7789<SPI, DC> { /* private fields */ }
Expand description

ST7789 driver.

Implementations§

Source§

impl<SPI: SpiDevice, DC: OutputPin> St7789<SPI, DC>

Source

pub const fn new(spi: SPI, dc: DC, panel: Panel, rotation: Rotation) -> Self

Wraps an SPI device and the DC pin. Call init next.

Source

pub async fn init( &mut self, script: &[InitStep], delay: &mut impl DelayNs, ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Runs script, then sets RGB565, rotation, inversion, and turns the display on.

Source

pub const fn geometry(&self) -> Geometry

Current drawable window.

Source

pub async fn set_rotation( &mut self, rotation: Rotation, ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Changes rotation. Frame memory is not redrawn.

Source

pub async fn command( &mut self, cmd: u8, params: &[u8], ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Sends a command followed by its parameters.

Source

pub async fn set_window( &mut self, x0: u16, y0: u16, x1: u16, y1: u16, ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Selects the inclusive window (x0, y0)..=(x1, y1) in logical coordinates. Coordinates beyond the visible area are the caller’s responsibility.

Source

pub async fn write_pixels( &mut self, bytes: &[u8], ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Streams big-endian RGB565 bytes into the current window.

Source

pub async fn write_rows( &mut self, y: u16, bytes: &[u8], ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Writes full-width rows starting at row y. bytes must hold whole rows; it is sent as one contiguous transfer.

Source

pub async fn set_display_on( &mut self, on: bool, ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Display on/off. Frame memory is kept while off.

Source

pub async fn set_sleep( &mut self, sleep: bool, delay: &mut impl DelayNs, ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Enters (true) or leaves sleep mode. The controller needs 120 ms between the two; this call waits that long after the command.

Source

pub async fn soft_reset( &mut self, delay: &mut impl DelayNs, ) -> Result<(), Error<<SPI as ErrorType>::Error, <DC as ErrorType>::Error>>

Software reset; prefer hard_reset when a reset pin is wired.

Source

pub fn release(self) -> (SPI, DC)

Returns the SPI device and DC pin.

Auto Trait Implementations§

§

impl<SPI, DC> Freeze for St7789<SPI, DC>
where SPI: Freeze, DC: Freeze,

§

impl<SPI, DC> RefUnwindSafe for St7789<SPI, DC>
where SPI: RefUnwindSafe, DC: RefUnwindSafe,

§

impl<SPI, DC> Send for St7789<SPI, DC>
where SPI: Send, DC: Send,

§

impl<SPI, DC> Sync for St7789<SPI, DC>
where SPI: Sync, DC: Sync,

§

impl<SPI, DC> Unpin for St7789<SPI, DC>
where SPI: Unpin, DC: Unpin,

§

impl<SPI, DC> UnsafeUnpin for St7789<SPI, DC>
where SPI: UnsafeUnpin, DC: UnsafeUnpin,

§

impl<SPI, DC> UnwindSafe for St7789<SPI, DC>
where SPI: UnwindSafe, DC: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.