cat-in-136 / ws2812-esp32-rmt-driver

WS2812 driver using ESP32 RMT for Rust
MIT License
40 stars 21 forks source link

Likely need help to use this crate. #32

Closed RoyalFoxy closed 10 months ago

RoyalFoxy commented 10 months ago

I'm a bit confused on how to use this crate. I currently have this code but it doesn't work. I basically just took the esp_idf_sys template and added code that I think should work? It's pretty unclear to me where to find proper basic examples that just turn all neopixels red or somthing similiar.

use esp_idf_sys as _;
use log::*;
use smart_leds::{SmartLedsWrite, RGB8};
use ws2812_esp32_rmt_driver::Ws2812Esp32Rmt;

const NUM_LEDS: usize = 100;
const COLOR: (u8, u8, u8) = (32, 0, 0);
const GPIO_PIN: u32 = 18;

fn main() {
    esp_idf_sys::link_patches();
    esp_idf_svc::log::EspLogger::initialize_default();

    let mut ws2812 = match Ws2812Esp32Rmt::new(NUM_LEDS.try_into().unwrap(), GPIO_PIN) {
        Ok(ws2812) => ws2812,
        Err(error) => {
            info!("{error:?}");
            loop {}
        }
    };

    let data: [RGB8; NUM_LEDS] = [RGB8 {
        r: COLOR.0,
        g: COLOR.1,
        b: COLOR.2,
    }; NUM_LEDS];

    ws2812.write(data.iter().cloned()).unwrap();
}

This code errors with the following lines

E (453) rmt: rmt_set_gpio(523): RMT CHANNEL ERR
E (463) rmt: rmt_config(686): set gpio for RMT driver failed
I (463) test: Ws2812Esp32RmtDriverError(EspError(258))

The third line is the info macro invocation which just prints out the debug display of the error.

RoyalFoxy commented 10 months ago

Looked at the examples and noticed that the first argument for Ws2812Esp32Rmt is the channel and not led count...