diff --git a/bathroom-esp32/.vscode/settings.json b/bathroom-esp32/.vscode/settings.json index b7fa1c1..989737b 100755 --- a/bathroom-esp32/.vscode/settings.json +++ b/bathroom-esp32/.vscode/settings.json @@ -12,7 +12,7 @@ "interface/ftdi/esp32_devkitj_v1.cfg", "target/esp32.cfg" ], - "idf.portWin": "COM7", + "idf.portWin": "COM8", "idf.pythonBinPathWin": "C:\\Projects\\Esp32\\espressif\\python_env\\idf5.3_py3.11_env\\Scripts\\python.exe", "idf.toolsPathWin": "C:\\Projects\\Esp32\\espressif", "idf.flashType": "UART" diff --git a/bathroom-esp32/.vscode/settings.json b/bathroom-esp32/.vscode/settings.json index b7fa1c1..989737b 100755 --- a/bathroom-esp32/.vscode/settings.json +++ b/bathroom-esp32/.vscode/settings.json @@ -12,7 +12,7 @@ "interface/ftdi/esp32_devkitj_v1.cfg", "target/esp32.cfg" ], - "idf.portWin": "COM7", + "idf.portWin": "COM8", "idf.pythonBinPathWin": "C:\\Projects\\Esp32\\espressif\\python_env\\idf5.3_py3.11_env\\Scripts\\python.exe", "idf.toolsPathWin": "C:\\Projects\\Esp32\\espressif", "idf.flashType": "UART" diff --git a/bathroom-esp32/main/main.cpp b/bathroom-esp32/main/main.cpp index d5888a5..48e448d 100755 --- a/bathroom-esp32/main/main.cpp +++ b/bathroom-esp32/main/main.cpp @@ -22,14 +22,16 @@ #include "esp_log.h" #include "led_strip.h" #include "sdkconfig.h" +#include "esp_random.h" static const char *TAG = "example"; /* Use project configuration menu (idf.py menuconfig) to choose the GPIO to blink, or you can edit the following line and set a number here. */ -#define BLINK_GPIO ((gpio_num_t)2) -#define CONFIG_BLINK_LED_GPIO 1 +#define BLINK_GPIO ((gpio_num_t)16) +#define CONFIG_BLINK_LED_STRIP 1 +#define CONFIG_BLINK_LED_STRIP_BACKEND_RMT 1 #define CONFIG_BLINK_PERIOD 3000 static uint8_t s_led_state = 0; @@ -43,7 +45,7 @@ /* If the addressable LED is enabled */ if (s_led_state) { /* Set the LED pixel using RGB from 0 (0%) to 255 (100%) for each color */ - led_strip_set_pixel(led_strip, 0, 16, 16, 16); + led_strip_set_pixel(led_strip, 0, esp_random() & 0x3F, esp_random() & 0x3F, esp_random() & 0x3F); /* Refresh the strip to send data */ led_strip_refresh(led_strip); } else { @@ -58,12 +60,17 @@ /* LED strip initialization with the GPIO and pixels number*/ led_strip_config_t strip_config = { .strip_gpio_num = BLINK_GPIO, - .max_leds = 1, // at least one LED on board + .max_leds = 1, + .led_pixel_format = LED_PIXEL_FORMAT_GRB, + .led_model = LED_MODEL_WS2812, + .flags = { .invert_out = false }, }; #if CONFIG_BLINK_LED_STRIP_BACKEND_RMT led_strip_rmt_config_t rmt_config = { + .clk_src = RMT_CLK_SRC_DEFAULT, .resolution_hz = 10 * 1000 * 1000, // 10MHz - .flags.with_dma = false, + .mem_block_symbols = 0, + .flags = { .with_dma = false }, }; ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip)); #elif CONFIG_BLINK_LED_STRIP_BACKEND_SPI