#![no_std]
#![no_main]
use esp32c3_hal::{clock::ClockControl, peripherals, prelude::*, rmt::Rmt, Delay, IO};
use esp_backtrace as _;
use esp_hal_smartled::{smartLedBuffer, SmartLedsAdapter};
use smart_leds::{
// brightness,
// gamma,
// hsv::{hsv2rgb, Hsv},
SmartLedsWrite,
RGB8
};
#[entry]
fn main() -> ! {
let peripherals = peripherals::Peripherals::take();
let system = peripherals.SYSTEM.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
// Configure RMT peripheral globally
let rmt = Rmt::new(peripherals.RMT, 80u32.MHz(), &clocks).unwrap();
// We use one of the RMT channels to instantiate a `SmartLedsAdapter` which can
// be used directly with all `smart_led` implementations
let rmt_buffer = smartLedBuffer!(8);
let mut led = SmartLedsAdapter::new(rmt.channel0, io.pins.gpio2, rmt_buffer);
// Initialize the Delay peripheral, and use it to toggle the LED state in a
// loop.
let mut delay = Delay::new(&clocks);
let mut data = [ RGB8 {
r: 255,
g: 0,
b: 0x10,
};8];
let empty = [RGB8::default(); 8];
data[1] = RGB8 {
r: 0,
g: 0x10,
b: 0,
};
data[2] = RGB8 {
r: 0x10,
g: 0,
b: 0,
};
loop {
led.write(data.iter().cloned()).unwrap();
delay.delay_ms(1000 as u16);
led.write(empty.iter().cloned()).unwrap();
delay.delay_ms(1000 as u16);
}
}