Available on non-
target_vendor="espressif"
only.Expand description
Mock of Low-level WS2812 ESP32 RMT driver.
If the target vendor does not equals to “espressif”, this mock is used instead of genuine Low-level WS2812 ESP32 RMT driver.
Fields§
§pixel_data: Option<Vec<u8>>
Pixel binary array to be written
Implementations§
source§impl Ws2812Esp32RmtDriver
impl Ws2812Esp32RmtDriver
sourcepub fn new(
_channel_num: u8,
_gpio_num: u32
) -> Result<Self, Ws2812Esp32RmtDriverError>
pub fn new(
_channel_num: u8,
_gpio_num: u32
) -> Result<Self, Ws2812Esp32RmtDriverError>
Creates a mock of Ws2812Esp32RmtDriver
.
All arguments shall be ignored and always returns Ok(_)
.
Examples found in repository?
More examples
src/lib_embedded_graphics.rs (line 74)
73 74 75 76 77 78 79 80 81 82 83 84 85
pub fn new(channel_num: u8, gpio_num: u32) -> Result<Self, Ws2812Esp32RmtDriverError> {
let driver = Ws2812Esp32RmtDriver::new(channel_num, gpio_num)?;
let data = std::iter::repeat(0)
.take(S::pixel_len() * CDev::BPP)
.collect::<Vec<_>>();
Ok(Self {
driver,
data,
brightness: u8::MAX,
changed: true,
_phantom: Default::default(),
})
}
sourcepub fn write(
&mut self,
pixel_data: &[u8]
) -> Result<(), Ws2812Esp32RmtDriverError>
pub fn write(
&mut self,
pixel_data: &[u8]
) -> Result<(), Ws2812Esp32RmtDriverError>
Writes GRB pixel binary slice.
Examples found in repository?
More examples
src/lib_smart_leds.rs (line 80)
69 70 71 72 73 74 75 76 77 78 79 80 81
fn write<T, I>(&mut self, iterator: T) -> Result<(), Self::Error>
where
T: Iterator<Item = I>,
I: Into<Self::Color>,
{
let mut pixel_data = Vec::new();
for color in iterator {
for v in CDev::from(color.into()).as_ref() {
pixel_data.push(*v)
}
}
self.driver.write(pixel_data.as_slice())
}
Auto Trait Implementations§
impl RefUnwindSafe for Ws2812Esp32RmtDriver
impl Send for Ws2812Esp32RmtDriver
impl Sync for Ws2812Esp32RmtDriver
impl Unpin for Ws2812Esp32RmtDriver
impl UnwindSafe for Ws2812Esp32RmtDriver
Blanket Implementations§
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> 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.