pub struct Ws2812Esp32RmtDriver {
    pub pixel_data: Option<Vec<u8>>,
}
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§

Creates a mock of Ws2812Esp32RmtDriver. All arguments shall be ignored and always returns Ok(_).

Examples found in repository?
src/lib_smart_leds.rs (line 54)
53
54
55
56
57
58
59
    pub fn new(channel_num: u8, gpio_num: u32) -> Result<Self, Ws2812Esp32RmtDriverError> {
        let driver = Ws2812Esp32RmtDriver::new(channel_num, gpio_num)?;
        Ok(Self {
            driver,
            phantom: Default::default(),
        })
    }
More examples
Hide additional 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(),
        })
    }

Writes GRB pixel binary slice.

Examples found in repository?
src/lib_embedded_graphics.rs (line 112)
110
111
112
113
114
115
116
    pub fn flush(&mut self) -> Result<(), Ws2812Esp32RmtDriverError> {
        if self.changed {
            self.driver.write(&self.data)?;
            self.changed = false;
        }
        Ok(())
    }
More examples
Hide additional 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§

Blanket Implementations§

Gets the TypeId of self. Read more
Casts the value.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Casts the value.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Casts the value.
Casts the value.
Casts the value.
Casts the value.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Casts the value.
Casts the value.
Casts the value.
Casts the value.