An ESP-IDF lib for WS2812B/WS2815 led strips. Works via SPI with DMA
Find a file
Данила Горнушко 45c4bc9417 fix typo
2023-07-16 18:29:49 +03:00
CMakeLists.txt first commit 2023-07-16 12:06:00 +03:00
esp_ws28xx.c first commit 2023-07-16 12:06:00 +03:00
esp_ws28xx.h first commit 2023-07-16 12:06:00 +03:00
idf_component.yml first commit 2023-07-16 12:06:00 +03:00
LICENSE add LICENSE 2023-07-16 12:21:11 +03:00
README.md fix typo 2023-07-16 18:29:49 +03:00

esp_ws28xx

A light and simple ESP-IDF lib for WS2812B/WS2815 led strips. Works via SPI with DMA. A fork of https://github.com/8-DK/ESP32_SPI_WS2812_idf/ with a lot of fixes, refactoring, improvements and flexability. Fixed bit format, added correct reset pulses and support of WS2815. 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;


void blink_led(void) {
    for(int i = 0 ; i < LED_NUM ; i++) {
        if (led_state_off) ws28xx_pixels[i] = (CRGB){.r=0,.g=0,.b=0};
        else ws28xx_pixels[i] = (CRGB){.r=50,.g=0,.b=0};
    }
    ws28xx_update();
}


void app_main(void) {
    ws28xx_init(LED_GPIO, WS2812B, LED_NUM);
    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);
    }
}