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>>
impl CydDisplayEsp<ExclusiveDevice<Spi<'static, Blocking>, Output<'static>, NoDelay>>
Sourcepub 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>
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>
impl<D: SpiDevice<u8>> CydDisplay for CydDisplayEsp<D>
Source§fn screen_size(&self) -> Size
fn screen_size(&self) -> Size
Screen size after applying the configured
Orientation:
320×240 in landscape or 240×320 in portrait. Read moreSource§fn background_color(&self) -> Rgb888
fn background_color(&self) -> Rgb888
The device default background color. Read more
Source§fn foreground_color(&self) -> Rgb888
fn foreground_color(&self) -> Rgb888
The device default foreground/text color. Read more
Source§fn background_565(&self) -> Rgb565
fn background_565(&self) -> Rgb565
The device default background color in the native
Rgb565 format. Read moreSource§fn foreground_565(&self) -> Rgb565
fn foreground_565(&self) -> Rgb565
The device default foreground/text color in the native
Rgb565 format. Read moreSource§fn fill_contiguous<I>(
&mut self,
rectangle: Rectangle,
pixels: I,
) -> Result<(), Error>where
I: IntoIterator<Item = Rgb565>,
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 moreSource§fn frame_mut(&mut self, rectangle: Rectangle) -> Self::Frame<'_>
fn frame_mut(&mut self, rectangle: Rectangle) -> Self::Frame<'_>
Borrow a frame covering
rectangle, cleared to the device background color. Read moreSource§fn full_frame_mut(&mut self) -> Self::Frame<'_>
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>,
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>
fn draw_items<const DRAW_ITEM_CAPACITY: usize>( &mut self, bounds: Rectangle, background_color: Rgb565, items: impl IntoIterator<Item = DrawItem>, ) -> Result<(), Self::Error>
Source§fn clear(&mut self) -> Result<(), Self::Error>
fn clear(&mut self) -> Result<(), Self::Error>
Clear the whole screen to the device default background color. Read more
Source§impl<D: SpiDevice<u8>> DisplayBackend for CydDisplayEsp<D>
impl<D: SpiDevice<u8>> DisplayBackend for CydDisplayEsp<D>
Source§type Frame<'a> = CydFrameEsp<'a, D>
where
Self: 'a
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<'_>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Casts the value.
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.