Struct LedPixelDrawTarget

Source
pub struct LedPixelDrawTarget<'d, CDraw, CDev, S, Data = Vec<u8>>
where CDraw: RgbColor, CDev: LedPixelColor + From<CDraw>, S: LedPixelShape, Data: DerefMut<Target = [u8]> + FromIterator<u8> + IntoIterator<Item = u8>,
{ /* private fields */ }
Available on crate feature embedded-graphics-core only.
Expand description

Target for embedded-graphics drawing operations of the LED pixels.

This is a generalization for the future extension. Use Ws2812DrawTarget for typical RGB LED (WS2812B/SK6812) consisting of 8-bit GRB (total 24-bit pixel).

  • CDraw - color type for embedded-graphics drawing operations
  • CDev - the LED pixel color type (device dependant). It shall be convertible from CDraw.
  • S - the LED pixel shape
  • Data - (optional) data storage type. It shall be Vec-like struct.

flush() operation shall be required to write changes from a framebuffer to the display.

For non-alloc no_std environment, Data should be explicitly set to some Vec-like struct: e.g., heapless::Vec<u8, PIXEL_LEN> where PIXEL_LEN equals to S::size() * CDev::BPP.

Implementations§

Source§

impl<'d, CDraw, CDev, S, Data> LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where CDraw: RgbColor, CDev: LedPixelColor + From<CDraw>, S: LedPixelShape, Data: DerefMut<Target = [u8]> + FromIterator<u8> + IntoIterator<Item = u8>,

Source

pub fn new<C: RmtChannel>( channel: impl Peripheral<P = C> + 'd, pin: impl Peripheral<P = impl OutputPin> + 'd, ) -> Result<Self, Ws2812Esp32RmtDriverError>

Create a new draw target.

channel shall be different between different pin.

Source

pub fn new_with_rmt_driver( tx: TxRmtDriver<'d>, ) -> Result<Self, Ws2812Esp32RmtDriverError>

Create a new draw target.

Source

pub fn set_brightness(&mut self, brightness: u8)

Set maximum brightness. Each channel values of the returned shall be scaled down to (brightness + 1) / 256.

Source

pub fn brightness(&self) -> u8

Returns maximum brightness.

Source

pub fn clear_with_black(&mut self) -> Result<(), Ws2812Esp32RmtDriverError>

Clear with black. Same operation as clear(black_color).

Source

pub fn flush(&mut self) -> Result<(), Ws2812Esp32RmtDriverError>

Write changes from a framebuffer to the LED pixels

Trait Implementations§

Source§

impl<'d, CDraw, CDev, S, Data> DrawTarget for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where CDraw: RgbColor, CDev: LedPixelColor + From<CDraw>, S: LedPixelShape, Data: DerefMut<Target = [u8]> + FromIterator<u8> + IntoIterator<Item = u8>,

Source§

type Color = CDraw

The pixel color type the targetted display supports.
Source§

type Error = Ws2812Esp32RmtDriverError

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

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

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

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

Fill the entire display with a solid color. 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§

impl<'d, CDraw, CDev, S, Data> OriginDimensions for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where CDraw: RgbColor, CDev: LedPixelColor + From<CDraw>, S: LedPixelShape, Data: DerefMut<Target = [u8]> + FromIterator<u8> + IntoIterator<Item = u8>,

Source§

fn size(&self) -> Size

Returns the size of the bounding box.

Auto Trait Implementations§

§

impl<'d, CDraw, CDev, S, Data> Freeze for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where Data: Freeze,

§

impl<'d, CDraw, CDev, S, Data> RefUnwindSafe for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where Data: RefUnwindSafe, CDraw: RefUnwindSafe, CDev: RefUnwindSafe, S: RefUnwindSafe,

§

impl<'d, CDraw, CDev, S, Data> Send for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where Data: Send, CDraw: Send, CDev: Send, S: Send,

§

impl<'d, CDraw, CDev, S, Data> Sync for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where Data: Sync, CDraw: Sync, S: Sync,

§

impl<'d, CDraw, CDev, S, Data> Unpin for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>
where Data: Unpin, CDraw: Unpin, CDev: Unpin, S: Unpin,

§

impl<'d, CDraw, CDev, S, Data = Vec<u8>> !UnwindSafe for LedPixelDrawTarget<'d, CDraw, CDev, S, Data>

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.