Struct mipidsi::Display

source ·
pub struct Display<DI, MODEL, RST>
where DI: WriteOnlyDataCommand, MODEL: Model, RST: OutputPin,
{ /* private fields */ }
Expand description

Display driver to connect to TFT displays.

Implementations§

source§

impl<DI, M, RST> Display<DI, M, RST>
where DI: WriteOnlyDataCommand, M: Model, RST: OutputPin,

source

pub fn orientation(&self) -> Orientation

Returns currently set options::Orientation

source

pub fn set_orientation(&mut self, orientation: Orientation) -> Result<(), Error>

Sets display options::Orientation with mirror image parameter

§Examples
use mipidsi::options::{Orientation, Rotation};

display.set_orientation(Orientation::default().rotate(Rotation::Deg180)).unwrap();
source

pub fn set_pixel( &mut self, x: u16, y: u16, color: M::ColorFormat ) -> Result<(), Error>

Sets a pixel color at the given coords.

§Arguments
  • x - x coordinate
  • y - y coordinate
  • color - the color value in pixel format of the display Model
§Examples
use embedded_graphics::pixelcolor::Rgb565;

display.set_pixel(100, 200, Rgb565::new(251, 188, 20)).unwrap();
source

pub fn set_pixels<T>( &mut self, sx: u16, sy: u16, ex: u16, ey: u16, colors: T ) -> Result<(), Error>
where T: IntoIterator<Item = M::ColorFormat>,

Sets pixel colors in a rectangular region.

The color values from the colors iterator will be drawn to the given region starting at the top left corner and continuing, row first, to the bottom right corner. No bounds checking is performed on the colors iterator and drawing will wrap around if the iterator returns more color values than the number of pixels in the given region.

This is a low level function, which isn’t intended to be used in regular user code. Consider using the fill_contiguous function from the embedded-graphics crate as an alternative instead.

§Arguments
  • sx - x coordinate start
  • sy - y coordinate start
  • ex - x coordinate end
  • ey - y coordinate end
  • colors - anything that can provide IntoIterator<Item = u16> to iterate over pixel data
source

pub fn set_vertical_scroll_region( &mut self, top_fixed_area: u16, bottom_fixed_area: u16 ) -> Result<(), Error>

Sets the vertical scroll region.

The top_fixed_area and bottom_fixed_area arguments can be used to define an area on the top and/or bottom of the display which won’t be affected by scrolling.

Note that this method is not affected by the current display orientation and will always scroll vertically relative to the default display orientation.

The combined height of the fixed area must not larger than the height of the framebuffer height in the default orientation.

After the scrolling region is defined the set_vertical_scroll_offset can be used to scroll the display.

source

pub fn set_vertical_scroll_offset(&mut self, offset: u16) -> Result<(), Error>

Sets the vertical scroll offset.

Setting the vertical scroll offset shifts the vertical scroll region upwards by offset pixels.

Use set_vertical_scroll_region to setup the scroll region, before using this method.

source

pub fn release(self) -> (DI, M, Option<RST>)

Release resources allocated to this driver back. This returns the display interface, reset pin and and the model deconstructing the driver.

source

pub fn set_tearing_effect( &mut self, tearing_effect: TearingEffect ) -> Result<(), Error>

Configures the tearing effect output.

source

pub fn is_sleeping(&self) -> bool

Returns true if display is currently set to sleep.

source

pub fn sleep<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Error>

Puts the display to sleep, reducing power consumption. Need to call Self::wake before issuing other commands

source

pub fn wake<D: DelayNs>(&mut self, delay: &mut D) -> Result<(), Error>

Wakes the display after it’s been set to sleep via Self::sleep

source

pub unsafe fn dcs(&mut self) -> &mut Dcs<DI>

Returns the DCS interface for sending raw commands.

§Safety

Sending raw commands to the controller can lead to undefined behaviour, because the rest of the code isn’t aware of any state changes that were caused by sending raw commands. The user must ensure that the state of the controller isn’t altered in a way that interferes with the normal operation of this crate.

Trait Implementations§

source§

impl<DI, M, RST> DrawTarget for Display<DI, M, RST>
where DI: WriteOnlyDataCommand, M: Model, RST: OutputPin,

§

type Error = DisplayError

Error type to return when a drawing operation fails. Read more
§

type Color = <M as Model>::ColorFormat

The pixel color type the targetted display supports.
source§

fn draw_iter<T>(&mut self, item: T) -> Result<(), Self::Error>
where T: IntoIterator<Item = Pixel<Self::Color>>,

Draw individual pixels to the display without a defined order. Read more
source§

fn fill_contiguous<I>( &mut self, area: &Rectangle, colors: I ) -> Result<(), Self::Error>
where I: IntoIterator<Item = Self::Color>,

Fill a given area with an iterator providing a contiguous stream of pixel colors. Read more
source§

fn fill_solid( &mut self, area: &Rectangle, color: Self::Color ) -> Result<(), Self::Error>

Fill a given area with a solid color. Read more
source§

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

Fill the entire display with a solid color. Read more
source§

impl<DI, MODEL, RST> OriginDimensions for Display<DI, MODEL, RST>
where DI: WriteOnlyDataCommand, MODEL: Model, RST: OutputPin,

source§

fn size(&self) -> Size

Returns the size of the bounding box.

Auto Trait Implementations§

§

impl<DI, MODEL, RST> Freeze for Display<DI, MODEL, RST>
where MODEL: Freeze, DI: Freeze, RST: Freeze,

§

impl<DI, MODEL, RST> RefUnwindSafe for Display<DI, MODEL, RST>
where MODEL: RefUnwindSafe, DI: RefUnwindSafe, RST: RefUnwindSafe,

§

impl<DI, MODEL, RST> Send for Display<DI, MODEL, RST>
where MODEL: Send, DI: Send, RST: Send,

§

impl<DI, MODEL, RST> Sync for Display<DI, MODEL, RST>
where MODEL: Sync, DI: Sync, RST: Sync,

§

impl<DI, MODEL, RST> Unpin for Display<DI, MODEL, RST>
where MODEL: Unpin, DI: Unpin, RST: Unpin,

§

impl<DI, MODEL, RST> UnwindSafe for Display<DI, MODEL, RST>
where MODEL: UnwindSafe, DI: UnwindSafe, RST: 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>,

§

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>,

§

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.