Alternate LED state to demonstrate HW bringup
This commit is contained in:
+15
-5
@@ -11,7 +11,10 @@ use defmt::info;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::spi::master::{Spi, Config as SpiConfig};
|
||||
use esp_hal::time::Rate;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use ws2812_rs::{WS2812SPI, SendColorBySPI, Color};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_: &core::panic::PanicInfo) -> ! {
|
||||
@@ -42,15 +45,22 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_rtos::start(timg0.timer0);
|
||||
|
||||
info!("Embassy initialized!");
|
||||
|
||||
// TODO: Spawn some tasks
|
||||
let _ = spawner;
|
||||
|
||||
const LED_SPI_HZ: u32 = 3_200_000;
|
||||
let spi = Spi::new(peripherals.SPI2,
|
||||
SpiConfig::default().with_frequency(Rate::from_hz(LED_SPI_HZ)))
|
||||
.unwrap()
|
||||
.with_mosi(peripherals.GPIO48);
|
||||
let mut led = WS2812SPI::new(spi);
|
||||
|
||||
info!("Padmapper initialized!");
|
||||
|
||||
loop {
|
||||
info!("Hello world!");
|
||||
led.color_send_by_spi(Color([0, 0, 8]), LED_SPI_HZ).unwrap();
|
||||
Timer::after(Duration::from_secs(1)).await;
|
||||
led.color_send_by_spi(Color([8, 0, 8]), LED_SPI_HZ).unwrap();
|
||||
Timer::after(Duration::from_secs(1)).await;
|
||||
}
|
||||
|
||||
// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0/examples
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user