From 858f1da0d880a472c8aa4814fc5db205d2ad9fb3 Mon Sep 17 00:00:00 2001 From: FReenen Date: Fri, 19 Jul 2024 16:50:54 +0200 Subject: [PATCH] update led controll --- rx_esp32/src/led.c | 10 ++++------ rx_esp32/src/main.c | 5 +++++ rx_esp32/src/wifi.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/rx_esp32/src/led.c b/rx_esp32/src/led.c index 3f492d2..5e63ba9 100644 --- a/rx_esp32/src/led.c +++ b/rx_esp32/src/led.c @@ -14,7 +14,7 @@ typedef struct { rmt_symbol_word_t reset_code; } rmt_led_strip_encoder_t; -rmt_channel_handle_t* led_rmt_channel; +rmt_channel_handle_t led_rmt_channel; rmt_led_strip_encoder_t* led_enc; rmt_led_strip_encoder_t* led_init_encoder() @@ -64,12 +64,10 @@ void led_init(void) .resolution_hz = 10 * 1000 * 1000, // 10 MHz .trans_queue_depth = 4, .flags.with_dma = false, - .flags.invert_out = false, // ?? + .flags.invert_out = false, }; rmt_new_tx_channel(&rmt_chan_config, &led_rmt_channel); led_enc = led_init_encoder(); - /* Set all LED off to clear all pixels */ - // led_strip_clear(led_strip); led_setRGB(0, 0, 0); } @@ -85,10 +83,10 @@ void led_setRGB(uint8_t r, uint8_t g, uint8_t b) rmt_transmit_config_t tx_conf = { .loop_count = 0, }; - uint8_t pixel = {g, r, b}; + uint8_t pixel[] = {g, r, b}; rmt_enable(led_rmt_channel); - rmt_transmit(led_rmt_channel, led_enc, pixel, 3, &tx_conf); + rmt_transmit(led_rmt_channel, led_enc->bytes_encoder, pixel, 3, &tx_conf); rmt_tx_wait_all_done(led_rmt_channel, -1); rmt_disable(led_rmt_channel); } diff --git a/rx_esp32/src/main.c b/rx_esp32/src/main.c index 7381560..56f488d 100644 --- a/rx_esp32/src/main.c +++ b/rx_esp32/src/main.c @@ -14,6 +14,7 @@ #include "utils.h" #include "commands.h" #include "wifi.h" +#include "led.h" bool volatile running = true; CMDList_t* cmdList; @@ -52,6 +53,9 @@ void app_main() { printChipInfo(); + led_init(); + // led_setRGB(150, 0, 0); + wifiInit(); wifi_connect(); @@ -67,6 +71,7 @@ void app_main() { * happened. */ if (bits & WIFI_CONNECTED_BIT) { + // led_setRGB(0, 150, 0); printf("INFO: main: connected to ap SSID '%s'\n", WIFI_SSID); } else if (bits & WIFI_FAIL_BIT) diff --git a/rx_esp32/src/wifi.c b/rx_esp32/src/wifi.c index 47e3475..935797c 100644 --- a/rx_esp32/src/wifi.c +++ b/rx_esp32/src/wifi.c @@ -44,7 +44,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_ if (s_retry_num < MAX_RETRY_ATTEMPTS) { s_retry_num++; - printf("INFO: wifi: retry num %d", s_retry_num); + printf("INFO: wifi: retry num %d\n", s_retry_num); for (unsigned long i=0; i < 10000000; i++) { // printf(".\n");