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 */ }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 operationsCDev- the LED pixel color type (device dependant). It shall be convertible fromCDraw.S- the LED pixel shapeData- (optional) data storage type. It shall beVec-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>,
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>,
Sourcepub fn new<C: RmtChannel>(
channel: impl Peripheral<P = C> + 'd,
pin: impl Peripheral<P = impl OutputPin> + 'd,
) -> Result<Self, Ws2812Esp32RmtDriverError>
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.
Sourcepub fn new_with_rmt_driver(
tx: TxRmtDriver<'d>,
) -> Result<Self, Ws2812Esp32RmtDriverError>
pub fn new_with_rmt_driver( tx: TxRmtDriver<'d>, ) -> Result<Self, Ws2812Esp32RmtDriverError>
Create a new draw target with TxRmtDriver.
The clock divider must be set to 1 for the driver configuration.
let driver_config = TransmitConfig::new()
.clock_divider(1); // Required parameter.
let driver = TxRmtDriver::new(channel, led_pin, &driver_config).unwrap();pub fn new_with_ws2812_driver( driver: Ws2812Esp32RmtDriver<'d>, ) -> Result<Self, Ws2812Esp32RmtDriverError>
Sourcepub fn set_brightness(&mut self, brightness: u8)
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.
Sourcepub fn brightness(&self) -> u8
pub fn brightness(&self) -> u8
Returns maximum brightness.
Sourcepub fn clear_with_black(&mut self) -> Result<(), Ws2812Esp32RmtDriverError>
pub fn clear_with_black(&mut self) -> Result<(), Ws2812Esp32RmtDriverError>
Clear with black.
Same operation as clear(black_color).
Sourcepub fn flush(&mut self) -> Result<(), Ws2812Esp32RmtDriverError>
pub fn flush(&mut self) -> Result<(), Ws2812Esp32RmtDriverError>
Write changes from a framebuffer to the LED pixels