WS2812 RMT Driver
API reference
Loading...
Searching...
No Matches
ws2812_control.h
Go to the documentation of this file.
1#pragma once
12#include "driver/gpio.h"
13#include "driver/rmt_tx.h"
14#include "driver/rmt_types.h"
15#include "esp_err.h"
16#include "led_strip_encoder.h"
17#include "sdkconfig.h"
18#include "ws2812_rmt_caps.h"
19#include <stdint.h>
20
26#define NUM_LEDS CONFIG_WS2812_NUM_LEDS
27
28#if CONFIG_WS2812_LED_TYPE_RGB
29#define WS2812_BITS_PER_LED 24
30#elif CONFIG_WS2812_LED_TYPE_RGBW
31#define WS2812_BITS_PER_LED 32
32#endif
33
35#define WS2812_LED_BUFFER_ITEMS (NUM_LEDS * WS2812_BITS_PER_LED)
36
38#define WS2812_T0H CONFIG_WS2812_T0H
40#define WS2812_T1H CONFIG_WS2812_T1H
42#define WS2812_T0L CONFIG_WS2812_T0L
43#define WS2812_T1L CONFIG_WS2812_T1L
44
46#define WS2812_DEFAULT_BRIGHTNESS CONFIG_WS2812_DEFAULT_BRIGHTNESS
47
50#ifdef __cplusplus
51extern "C" {
52#endif
53
63struct led_state {
65 uint32_t leds[NUM_LEDS];
66};
67
79esp_err_t ws2812_control_init(gpio_num_t gpio_num, int channel);
80
92esp_err_t ws2812_write_leds(struct led_state new_state);
93
102void ws2812_set_brightness(uint8_t brightness);
103
104#ifdef __cplusplus
105}
106#endif
Desired colors for a chain of LEDs.
Definition ws2812_control.h:63
uint32_t leds[NUM_LEDS]
Definition ws2812_control.h:65
#define NUM_LEDS
Definition ws2812_control.h:26
esp_err_t ws2812_write_leds(struct led_state new_state)
Send LED colour data.
Definition ws2812_control.c:87
void ws2812_set_brightness(uint8_t brightness)
Set global brightness for subsequent transmissions.
Definition ws2812_control.c:110
esp_err_t ws2812_control_init(gpio_num_t gpio_num, int channel)
Initialise the RMT peripheral for WS2812 output.
Definition ws2812_control.c:43
RMT resources the driver requests per strip (shared by the C and C++ APIs).