You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use anyhow::Result;
use esp_idf_hal::delay::FreeRtos;
use esp_idf_hal::peripherals::Peripherals;
use esp_idf_hal::spi::{config::Config, SpiDeviceDriver, SpiDriver, SpiDriverConfig, SPI2};
use esp_idf_svc::log::EspLogger;
use esp_idf_sys::{self as _};
use log::info;
use smart_leds::{SmartLedsWrite, RGB8};
use ws2812_spi::Ws2812;
fn main() -> Result<()> {
esp_idf_svc::sys::link_patches();
EspLogger::initialize_default();
let peripherals = Peripherals::take()?;
let spi = peripherals.spi2;
let sclk = peripherals.pins.gpio6; // SCLK
let miso = peripherals.pins.gpio4; // MISO
let mosi = peripherals.pins.gpio7; // MOSI
let cs = peripherals.pins.gpio10; // Chip Select (unused for LED control)
println!("Starting WS2812 LED control");
let driver = SpiDriver::new::<SPI2>(spi, sclk, mosi, Some(miso), &SpiDriverConfig::new())?;
// WS2812 requires a specific SPI configuration
let config = Config::new().baudrate(3_000_000.into());
let mut spi_device = SpiDeviceDriver::new(&driver, Some(cs), &config)?;
let mut ws = Ws2812::new(spi_device);
let mut delay = FreeRtos;
// Data arrays for LED colors
let mut data: [RGB8; 3] = [RGB8::default(); 3];
let empty: [RGB8; 3] = [RGB8::default(); 3];
loop {
data[0] = RGB8 {
r: 0,
g: 0,
b: 0x10,
}; // Blue
data[1] = RGB8 {
r: 0,
g: 0x10,
b: 0,
}; // Green
data[2] = RGB8 {
r: 0x10,
g: 0,
b: 0,
}; // Red
// Write color data to the LEDs
ws.write(data.iter().cloned()).unwrap();
delay.delay_ms(1000);
// Turn off LEDs
ws.write(empty.iter().cloned()).unwrap();
delay.delay_ms(1000);
}
}
However, I get the following error:
the trait bound `SpiDeviceDriver<'_, &SpiDriver<'_>>: embedded_hal::spi::FullDuplex<u8>` is not satisfied
the trait `embedded_hal::spi::FullDuplex<u8>` is not implemented for `SpiDeviceDriver<'_, &SpiDriver<'_>>`
The text was updated successfully, but these errors were encountered:
I created this based on the STM32 example:
However, I get the following error:
The text was updated successfully, but these errors were encountered: