Skip to main content

CydDisplayEsp

Struct CydDisplayEsp 

Source
pub struct CydDisplayEsp<D: SpiDevice<u8> = ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, NoDelay>> { /* private fields */ }
Expand description

An owned CYD-family ESP32 display component.

D is the underlying embedded-hal SPI device type; it defaults to an exclusively-owned SPI peripheral. Shared-bus backends (see CydEspOneSpi) instantiate this with an embedded_hal_bus::spi::RefCellDevice instead.

Start with the cyd module example. The display-only constructor and static-storage pattern are shown by the CydDisplayEsp::new example.

Implementations§

Source§

impl CydDisplayEsp<ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, NoDelay>>

Source

pub fn new<const PIXEL_COUNT: usize>( statics: &'static CydStaticEsp<PIXEL_COUNT>, display_spi: impl Instance + 'static, display_sck_pin: impl PeripheralOutput<'static>, display_mosi_pin: impl PeripheralOutput<'static>, display_miso_pin: impl PeripheralInput<'static>, display_cs_pin: impl OutputPin + 'static, display_dc_pin: impl OutputPin + 'static, display_rst_pin: impl OutputPin + 'static, display_backlight_pin: impl OutputPin + 'static, display_spi_hz: u32, orientation: Orientation, background_color: Rgb888, foreground_color: Rgb888, font: &'static MonoFont<'static>, ) -> Result<Self, Error>

Construct a display-only CYD display component that owns its draw buffer.

Choosing the pixel buffer capacity is the most important construction decision: statics determines both static RAM use and the largest buffered region. See CydEsp::new_static for the sizing choices.

use device_envoy_esp::{Result, cyd::{CydDisplay, CydDisplayEsp, CydEsp, DEFAULT_DISPLAY_SPI_HZ, DEFAULT_FONT, Orientation}};
use embedded_graphics::{pixelcolor::Rgb888, prelude::RgbColor};
async fn construct(p: esp_hal::peripherals::Peripherals) -> Result<()> {
    static CYD_STATIC: device_envoy_esp::cyd::CydStaticEsp<0> = CydEsp::new_static();
    let display = CydDisplayEsp::new(&CYD_STATIC, p.SPI2, p.GPIO1, p.GPIO2, p.GPIO3,
        p.GPIO4, p.GPIO5, p.GPIO7, p.GPIO8, DEFAULT_DISPLAY_SPI_HZ,
        Orientation::Landscape, Rgb888::BLACK, Rgb888::WHITE, &DEFAULT_FONT)?;
    assert_eq!(display.screen_size(), Orientation::Landscape.size());
    Ok(())
}

Trait Implementations§

Source§

impl<D: SpiDevice<u8>> CydDisplay for CydDisplayEsp<D>

Source§

fn screen_size(&self) -> Size

Screen size after applying the configured Orientation: 320×240 in landscape or 240×320 in portrait. Read more
Source§

fn background_color(&self) -> Rgb888

The device default background color. Read more
Source§

fn foreground_color(&self) -> Rgb888

The device default foreground/text color. Read more
Source§

fn background_565(&self) -> Rgb565

The device default background color in the native Rgb565 format. Read more
Source§

fn foreground_565(&self) -> Rgb565

The device default foreground/text color in the native Rgb565 format. Read more
Source§

fn fill_rectangle( &mut self, rectangle: Rectangle, color: Rgb565, ) -> Result<(), Error>

Fill rectangle immediately with color in logical display coordinates. Read more
Source§

fn fill_contiguous<I>( &mut self, rectangle: Rectangle, pixels: I, ) -> Result<(), Error>
where I: IntoIterator<Item = Rgb565>,

Fill rectangle immediately from row-major native-color pixels. Read more
Source§

fn to_rgb565(&self, color: Rgb888) -> Rgb565

Convert an Rgb888 color to the device’s native Rgb565 format. Read more
Source§

fn frame_mut(&mut self, rectangle: Rectangle) -> Self::Frame<'_>

Borrow a frame covering rectangle, cleared to the device background color. Read more
Source§

fn full_frame_mut(&mut self) -> Self::Frame<'_>

Borrow a full-screen frame, cleared to the device background color. Read more
Source§

fn fill_contiguous_full<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where I: IntoIterator<Item = Rgb565>,

Fill the complete screen immediately from row-major native-color pixels. Read more
Source§

fn draw_items<const DRAW_ITEM_CAPACITY: usize>( &mut self, bounds: Rectangle, background_color: Rgb565, items: impl IntoIterator<Item = DrawItem>, ) -> Result<(), Self::Error>

Draw items immediately inside bounds. Read more
Source§

fn clear(&mut self) -> Result<(), Self::Error>

Clear the whole screen to the device default background color. Read more
Source§

fn fill(&mut self, color: Rgb565) -> Result<(), Self::Error>

Fill the whole screen with an explicit color. Read more
Source§

fn for_each_tile<'a, F>( &'a mut self, grid: TileGrid, draw: F, ) -> impl Future<Output = Result<(), Self::Error>> + 'a
where Self: Sized, F: for<'frame> FnMut(&mut Self::Frame<'frame>) + 'a,

Draw and flush each tile in grid. Read more
Source§

impl<D: SpiDevice<u8>> Debug for CydDisplayEsp<D>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D: SpiDevice<u8>> DisplayBackend for CydDisplayEsp<D>

Source§

type Error = Error

Error returned when a frame is flushed.
Source§

type Frame<'a> = CydFrameEsp<'a, D> where Self: 'a

Frame type created by this display implementation.
Source§

fn create_frame_mut(&mut self, rectangle: Rectangle) -> Self::Frame<'_>

Create a frame covering rectangle in logical display coordinates.

Auto Trait Implementations§

§

impl<D = ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, NoDelay>> !RefUnwindSafe for CydDisplayEsp<D>

§

impl<D = ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, NoDelay>> !Send for CydDisplayEsp<D>

§

impl<D = ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, NoDelay>> !Sync for CydDisplayEsp<D>

§

impl<D = ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, NoDelay>> !UnwindSafe for CydDisplayEsp<D>

§

impl<D> Freeze for CydDisplayEsp<D>
where CydDisplayEsp<D>: Freeze,

§

impl<D> Unpin for CydDisplayEsp<D>
where CydDisplayEsp<D>: Unpin,

§

impl<D> UnsafeUnpin for CydDisplayEsp<D>
where CydDisplayEsp<D>: UnsafeUnpin,

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> Same for T

Source§

type Output = T

Should always be Self
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> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
Source§

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

Source§

type Error = !

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.