|
WS2812 RMT Driver
API reference
|
#include "ws2812_control.h"#include "driver/rmt_tx.h"#include "driver/rmt_types.h"#include "esp_check.h"#include "esp_err.h"#include "esp_log.h"#include "freertos/FreeRTOS.h"#include "led_strip_encoder.h"Macros | |
| #define | BYTES_PER_LED 3 |
| #define | WS2812_RMT_RESOLUTION_HZ (10 * 1000 * 1000) |
Functions | |
| esp_err_t | ws2812_control_init (gpio_num_t gpio_num, int channel) |
| Initialise the RMT peripheral for WS2812 output. | |
| esp_err_t | ws2812_write_leds (struct led_state new_state) |
| Send LED colour data. | |
| void | ws2812_set_brightness (uint8_t brightness) |
| Set global brightness for subsequent transmissions. | |
| #define BYTES_PER_LED 3 |
| #define WS2812_RMT_RESOLUTION_HZ (10 * 1000 * 1000) |
| esp_err_t ws2812_control_init | ( | gpio_num_t | gpio_num, |
| int | channel | ||
| ) |
Initialise the RMT peripheral for WS2812 output.
This function must be called once before any LED data is transmitted. On failure everything it allocated is released, so it can be called again.
| gpio_num | GPIO connected to the LED strip. |
| channel | Unused: ESP-IDF v5's RMT driver picks a free channel itself. |
| void ws2812_set_brightness | ( | uint8_t | brightness | ) |
Set global brightness for subsequent transmissions.
All LED values are scaled by this factor before being sent. 255 means full brightness.
| brightness | Brightness level 0-255. |
| esp_err_t ws2812_write_leds | ( | struct led_state | new_state | ) |
Send LED colour data.
Sends every LED's colour (green, red, blue[, white], scaled by the brightness) with the Kconfig bit timing, then the reset code that latches the frame. Blocks the calling task until the frame has been transmitted.
| new_state | Desired LED colours. |