#include "led.h" #include #include #define BUILDIN_LED_GPIO 8 led_strip_handle_t led_strip; void led_init(void) { // LED strip general initialization, according to your led board design led_strip_config_t strip_config = { .strip_gpio_num = BUILDIN_LED_GPIO, // The GPIO that connected to the LED strip's data line .max_leds = 1, // The number of LEDs in the strip, .led_pixel_format = LED_PIXEL_FORMAT_GRB, // Pixel format of your LED strip .led_model = LED_MODEL_WS2812, // LED strip model .flags.invert_out = false, // whether to invert the output signal }; // LED strip backend configuration: RMT led_strip_rmt_config_t rmt_config = { #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) .rmt_channel = 0, #else .clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption .resolution_hz = 10 * 1000 * 1000, // RMT counter clock frequency .flags.with_dma = false, // DMA feature is available on ESP target like ESP32-S3 #endif }; // LED Strip object handle led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip); led_setRGB(0, 0, 0); } void led_deinit(void) { led_strip_del(led_strip); } void led_setRGB(uint8_t r, uint8_t g, uint8_t b) { led_strip_set_pixel(led_strip, 0, r, g, b); led_strip_refresh(led_strip); }