Struct Ssd1331

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

The implementation of the driver.

Can be used with embedded-graphics crate in async frameworks (e.g. Embassy). Since the embedded-graphics API is synchronous, the driver assumes use of a framebuffer, and provides an async method to transfer its contents to the display. Full-size framebuffer requires ~12Kb (6Kb for 8-bit color mode). The driver allows using a smaller buffer and addressing a sub-area of the display; for example, it’s possible to draw monospaced text one character at a time, or mix text and graphics areas.

The driver dutifully propagates all errors from the HAL, but the display controller is stateful and the driver doesn’t attempt to return it to a known good state after an error. You can call init() to hard-reset the display and reinitialize the driver after an error.

Implementations§

Source§

impl<RST, DC, SPI, PinE, SpiE> Ssd1331<RST, DC, SPI>
where RST: OutputPin<Error = PinE>, DC: OutputPin<Error = PinE>, SPI: SpiDevice<Error = SpiE>,

Source

pub async fn new( data_mapping: Config, rst: RST, dc: DC, spi: SPI, delay: &mut impl DelayNs, ) -> Result<Self, Error<PinE, SpiE>>

Creates a new driver instance and initializes the display.

Requires GPIO output pins connected to RST and DC pins on the display, and a SPI device with SDO and SCK outputs connected to the display. The CS (chip select) pin of the display can be controlled by the SPI device, or you can simply tie it low, and pass a DummyPin to the SPI device. SPI bus should be configured to MODE_0, MSB first (usually the default). Frequencies up to 50 MHz seem to work fine, even though the display datasheet specifies ~6 MHz max.

Source

pub async fn init( &mut self, delay: &mut impl DelayNs, ) -> Result<(), Error<PinE, SpiE>>

Hard-resets and re-initializes the display.

Also clears the display RAM. This will take a few milliseconds. Instances returned by Self::new are already initialized.

Source

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

Consumes the driver and returns the peripherals to you.

Source

pub async fn write_pixels( &mut self, data: &[u8], bit_depth: BitDepth, area: Rectangle, ) -> Result<(), Error<PinE, SpiE>>

Sends the data to the given area of the display’s frame buffer.

The area is in your logical display coordinates; e.g if you use Config::ccw90, the logical size is (64, 96) and the (0, 0) is the top-right corner of the un-rotated physical screen.

You can fill the area using a smaller buffer by repeatedly calling this method and passing the same area. Sending more data than fits in the area will wrap around and overwrite the beginning of the area.

§Panics

If the area is empty or not completely contained within the display bounds.

Trait Implementations§

Source§

impl<RST, DC, SPI> OriginDimensions for Ssd1331<RST, DC, SPI>

Source§

fn size(&self) -> Size

Returns the size of the bounding box.
Source§

impl<RST, DC, SPI, PinE, SpiE> WritePixels for Ssd1331<RST, DC, SPI>
where RST: OutputPin<Error = PinE>, DC: OutputPin<Error = PinE>, SPI: SpiDevice<Error = SpiE>,

Source§

async fn write_pixels( &mut self, data: &[u8], bit_depth: BitDepth, area: Rectangle, )

Source§

async fn flush<C>(&mut self, fb: &Framebuffer<'_, C>, top_left: Point)
where C: PixelColor + ToBytes,

Transfers the contents of the framebuffer to the display.

Auto Trait Implementations§

§

impl<RST, DC, SPI> Freeze for Ssd1331<RST, DC, SPI>
where RST: Freeze, DC: Freeze, SPI: Freeze,

§

impl<RST, DC, SPI> RefUnwindSafe for Ssd1331<RST, DC, SPI>

§

impl<RST, DC, SPI> Send for Ssd1331<RST, DC, SPI>
where RST: Send, DC: Send, SPI: Send,

§

impl<RST, DC, SPI> Sync for Ssd1331<RST, DC, SPI>
where RST: Sync, DC: Sync, SPI: Sync,

§

impl<RST, DC, SPI> Unpin for Ssd1331<RST, DC, SPI>
where RST: Unpin, DC: Unpin, SPI: Unpin,

§

impl<RST, DC, SPI> UnwindSafe for Ssd1331<RST, DC, SPI>
where RST: UnwindSafe, DC: UnwindSafe, SPI: 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> Dimensions for T

Source§

fn bounding_box(&self) -> Rectangle

Returns the bounding box.
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.