test LED Array works..

This commit is contained in:
Philipp_EndevourOS 2025-08-13 01:51:00 +02:00
parent fa6d1f024c
commit 593d98df74
2 changed files with 11 additions and 14 deletions

View File

@ -55,6 +55,9 @@ use crate::init::wifi;
* *
*************************************************/ *************************************************/
const NUM_LEDS: usize = 66;
const LED_BUFFER_SIZE: usize = NUM_LEDS * 25;
#[panic_handler] #[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! { fn panic(info: &core::panic::PanicInfo) -> ! {
loop { loop {
@ -70,6 +73,7 @@ pub async fn hardware_init(
Uart<'static, Async>, Uart<'static, Async>,
Stack<'static>, Stack<'static>,
I2c<'static, Async>, I2c<'static, Async>,
SmartLedsAdapterAsync<ConstChannelAccess<esp_hal::rmt::Tx, 0>, LED_BUFFER_SIZE>,
GPIO21<'static>, GPIO21<'static>,
) { ) {
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max()); let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
@ -112,18 +116,11 @@ pub async fn hardware_init(
debug!("hardware init done"); debug!("hardware init done");
let level = 100; let level = 255;
let led_array: [RGB8; 66] = [RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, led.write(brightness([BLUE; NUM_LEDS].into_iter(), level)).await.unwrap();
RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE,
RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE,
RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE,
RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE, RED, GREEN, BLUE,
RED, GREEN, BLUE, RED, BLUE, RED];
led.write(brightness(led_array.into_iter(), level)).await.unwrap(); (uart_device, stack, i2c_device, led, buzzer_gpio)
(uart_device, stack, i2c_device, buzzer_gpio)
} }
// Initialize the level shifter for the NFC reader and LED (output-enable (OE) input is low, all outputs are placed in the high-impedance (Hi-Z) state) // Initialize the level shifter for the NFC reader and LED (output-enable (OE) input is low, all outputs are placed in the high-impedance (Hi-Z) state)
@ -200,7 +197,7 @@ pub fn setup_buzzer(buzzer_gpio: GPIO21<'static>) -> Output<'static> {
fn setup_led( fn setup_led(
rmt: RMT<'static>, rmt: RMT<'static>,
led_gpio: GPIO1<'static>, led_gpio: GPIO1<'static>,
) -> SmartLedsAdapterAsync<ConstChannelAccess<esp_hal::rmt::Tx, 0>, 1650> { ) -> SmartLedsAdapterAsync<ConstChannelAccess<esp_hal::rmt::Tx, 0>, LED_BUFFER_SIZE> {
debug!("setup led"); debug!("setup led");
let rmt: Rmt<'_, esp_hal::Async> = { let rmt: Rmt<'_, esp_hal::Async> = {
let frequency: Rate = Rate::from_mhz(80); let frequency: Rate = Rate::from_mhz(80);
@ -210,9 +207,9 @@ fn setup_led(
.into_async(); .into_async();
let rmt_channel = rmt.channel0; let rmt_channel = rmt.channel0;
let rmt_buffer = [0_u32; buffer_size_async(66)]; let rmt_buffer = [0_u32; buffer_size_async(NUM_LEDS)];
let led: SmartLedsAdapterAsync<_, 1650> = let led: SmartLedsAdapterAsync<_, LED_BUFFER_SIZE> =
SmartLedsAdapterAsync::new(rmt_channel, led_gpio, rmt_buffer); SmartLedsAdapterAsync::new(rmt_channel, led_gpio, rmt_buffer);
led led

View File

@ -30,7 +30,7 @@ type TallyPublisher = Publisher<'static, NoopRawMutex, TallyID, 8, 2, 1>;
#[esp_hal_embassy::main] #[esp_hal_embassy::main]
async fn main(mut spawner: Spawner) { async fn main(mut spawner: Spawner) {
let (uart_device, stack, _i2c, buzzer_gpio) = let (uart_device, stack, _i2c, _led, buzzer_gpio) =
init::hardware::hardware_init(&mut spawner).await; init::hardware::hardware_init(&mut spawner).await;
wait_for_stack_up(stack).await; wait_for_stack_up(stack).await;