update led controll

This commit is contained in:
Laila van Reenen 2024-07-19 16:50:54 +02:00
parent ce3c2402db
commit 858f1da0d8
Signed by: LailaTheElf
GPG Key ID: 1F4E6EE3E6DDF769
3 changed files with 10 additions and 7 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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");