2023-07-16 12:18:43 +03:00
# esp_ws28xx
2023-07-16 18:29:49 +03:00
A light and simple ESP-IDF lib for WS2812B/WS2815 led strips. Works via SPI with DMA.
2023-10-01 10:24:28 -06:00
A fork of https://github.com/8-DK/ESP32_SPI_WS2812_idf/ with a lot of fixes, refactoring, improvements, and higher flexibility. Fixed bit format, added correct reset pulses, and support of WS2815.
2023-07-16 12:18:43 +03:00
Tested with esp-idf v5.1 and esp32-c3.
# Example of usage
Just create folder `components` in the root of your project and clone this repo to the created folder.
Minimal working example (blink):
```
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "esp_ws28xx.h"
#define LED_GPIO 13
#define LED_NUM 10
static const char *TAG = "example";
static uint8_t led_state_off = 0;
2023-07-17 10:57:02 +03:00
CRGB* ws2812_buffer;
2023-07-16 12:18:43 +03:00
void blink_led(void) {
2023-07-17 10:57:02 +03:00
for(int i = 0; i < LED_NUM ; i + + ) {
if (led_state_off) ws2812_buffer[i] = (CRGB){.r=0, .g=0, .b=0};
else ws2812_buffer[i] = (CRGB){.r=50, .g=0, .b=0};
2023-07-16 12:18:43 +03:00
}
2023-07-17 10:57:02 +03:00
ESP_ERROR_CHECK_WITHOUT_ABORT(ws28xx_update());
2023-07-16 12:18:43 +03:00
}
void app_main(void) {
2023-07-17 10:57:02 +03:00
ESP_ERROR_CHECK_WITHOUT_ABORT(ws28xx_init(LED_GPIO, WS2812B, LED_NUM, &ws2812_buffer));
2023-07-16 12:18:43 +03:00
while (1) {
ESP_LOGI(TAG, "Turning the LED strip %s!", led_state_off == true ? "ON" : "OFF");
blink_led();
led_state_off = !led_state_off;
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
```