mirror of
				https://github.com/Djeeberjr/fw-anwesenheit.git
				synced 2025-11-04 07:34:10 +00:00 
			
		
		
		
	test LED Array works..
This commit is contained in:
		
							parent
							
								
									fa6d1f024c
								
							
						
					
					
						commit
						593d98df74
					
				@ -55,6 +55,9 @@ use crate::init::wifi;
 | 
			
		||||
 *
 | 
			
		||||
 *************************************************/
 | 
			
		||||
 | 
			
		||||
const NUM_LEDS: usize  = 66;
 | 
			
		||||
const LED_BUFFER_SIZE: usize = NUM_LEDS * 25;
 | 
			
		||||
 | 
			
		||||
#[panic_handler]
 | 
			
		||||
fn panic(info: &core::panic::PanicInfo) -> ! {
 | 
			
		||||
    loop {
 | 
			
		||||
@ -70,6 +73,7 @@ pub async fn hardware_init(
 | 
			
		||||
    Uart<'static, Async>,
 | 
			
		||||
    Stack<'static>,
 | 
			
		||||
    I2c<'static, Async>,
 | 
			
		||||
    SmartLedsAdapterAsync<ConstChannelAccess<esp_hal::rmt::Tx, 0>, LED_BUFFER_SIZE>,
 | 
			
		||||
    GPIO21<'static>,
 | 
			
		||||
) {
 | 
			
		||||
    let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
 | 
			
		||||
@ -112,18 +116,11 @@ pub async fn hardware_init(
 | 
			
		||||
 | 
			
		||||
    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,
 | 
			
		||||
 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([BLUE; NUM_LEDS].into_iter(), level)).await.unwrap();
 | 
			
		||||
 | 
			
		||||
    led.write(brightness(led_array.into_iter(), level)).await.unwrap();
 | 
			
		||||
 | 
			
		||||
    (uart_device, stack, i2c_device, buzzer_gpio)
 | 
			
		||||
    (uart_device, stack, i2c_device, led, 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)
 | 
			
		||||
@ -200,7 +197,7 @@ pub fn setup_buzzer(buzzer_gpio: GPIO21<'static>) -> Output<'static> {
 | 
			
		||||
fn setup_led(
 | 
			
		||||
    rmt: RMT<'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");
 | 
			
		||||
    let rmt: Rmt<'_, esp_hal::Async> = {
 | 
			
		||||
        let frequency: Rate = Rate::from_mhz(80);
 | 
			
		||||
@ -210,9 +207,9 @@ fn setup_led(
 | 
			
		||||
    .into_async();
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
    led
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,7 @@ type TallyPublisher = Publisher<'static, NoopRawMutex, TallyID, 8, 2, 1>;
 | 
			
		||||
 | 
			
		||||
#[esp_hal_embassy::main]
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
    wait_for_stack_up(stack).await;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user