HF-WS2812 Driver 0.1.0-dev
HF-WS2812 ESP32 RMT Driver
Loading...
Searching...
No Matches
ws2812_control.h
Go to the documentation of this file.
1#pragma once
7#include "driver/gpio.h"
8#include "driver/rmt_tx.h"
9#include "driver/rmt_types.h"
10#include "esp_err.h"
11#include "led_strip_encoder.h"
12#include "sdkconfig.h"
13#include <stdint.h>
14
20#define NUM_LEDS CONFIG_WS2812_NUM_LEDS
21
22#if CONFIG_WS2812_LED_TYPE_RGB
23#define WS2812_BITS_PER_LED 24
24#elif CONFIG_WS2812_LED_TYPE_RGBW
25#define WS2812_BITS_PER_LED 32
26#endif
27
29#define WS2812_LED_BUFFER_ITEMS (NUM_LEDS * WS2812_BITS_PER_LED)
30
32#define WS2812_T0H CONFIG_WS2812_T0H
34#define WS2812_T1H CONFIG_WS2812_T1H
36#define WS2812_T0L CONFIG_WS2812_T0L
37#define WS2812_T1L CONFIG_WS2812_T1L
38
40#define WS2812_DEFAULT_BRIGHTNESS CONFIG_WS2812_DEFAULT_BRIGHTNESS
41
44#ifdef __cplusplus
45extern "C" {
46#endif
47
56struct led_state {
58 uint32_t leds[NUM_LEDS];
59};
60
71esp_err_t ws2812_control_init(gpio_num_t gpio_num, int channel);
72
82esp_err_t ws2812_write_leds(struct led_state new_state);
83
92void ws2812_set_brightness(uint8_t brightness);
93
94#ifdef __cplusplus
95}
96#endif
Desired colors for a chain of LEDs.
Definition ws2812_control.h:56
uint32_t leds[NUM_LEDS]
Definition ws2812_control.h:58
#define NUM_LEDS
Definition ws2812_control.h:20
esp_err_t ws2812_write_leds(struct led_state new_state)
Send LED colour data.
Definition ws2812_control.c:91
void ws2812_set_brightness(uint8_t brightness)
Set global brightness for subsequent transmissions.
Definition ws2812_control.c:104
esp_err_t ws2812_control_init(gpio_num_t gpio_num, int channel)
Initialise the RMT peripheral for WS2812 output.
Definition ws2812_control.c:59