|
HF-WS2812 Driver 0.1.0-dev
HF-WS2812 ESP32 RMT Driver
|
#include "ws2812_control.h"#include "driver/rmt_tx.h"#include "driver/rmt_types.h"#include "esp_check.h"#include "esp_err.h"#include "freertos/FreeRTOS.h"#include "led_strip_encoder.h"Macros | |
| #define | LED_RMT_TX_CHANNEL CONFIG_WS2812_LED_RMT_TX_CHANNEL |
| #define | LED_RMT_TX_GPIO CONFIG_WS2812_LED_RMT_TX_GPIO |
| #define | LED_BUFFER_ITEMS (NUM_LEDS * BITS_PER_LED_CMD) |
| #define | T0H CONFIG_WS2812_T0H |
| #define | T1H CONFIG_WS2812_T1H |
| #define | T0L CONFIG_WS2812_T0L |
| #define | T1L CONFIG_WS2812_T1L |
Functions | |
| esp_err_t | ws2812_control_init (gpio_num_t gpio_num, int channel) |
| Initialise the RMT driver for WS2812 output. | |
| esp_err_t | ws2812_write_leds (struct led_state new_state) |
| Transmit colour values to the LED chain. | |
| void | ws2812_set_brightness (uint8_t brightness) |
| Set global brightness for subsequent transmissions. | |
| #define LED_BUFFER_ITEMS (NUM_LEDS * BITS_PER_LED_CMD) |
| #define LED_RMT_TX_CHANNEL CONFIG_WS2812_LED_RMT_TX_CHANNEL |
| #define LED_RMT_TX_GPIO CONFIG_WS2812_LED_RMT_TX_GPIO |
| #define T0H CONFIG_WS2812_T0H |
| #define T0L CONFIG_WS2812_T0L |
| #define T1H CONFIG_WS2812_T1H |
| #define T1L CONFIG_WS2812_T1L |
| esp_err_t ws2812_control_init | ( | gpio_num_t | gpio_num, |
| int | channel ) |
Initialise the RMT driver for WS2812 output.
Initialise the RMT peripheral for WS2812 output.
Must be called once before any LED data is transmitted. The pin and channel can be chosen at runtime.
| gpio_num | GPIO connected to the LED strip. |
| channel | RMT channel used for transmission. |
| 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 | ) |
Transmit colour values to the LED chain.
Send LED colour data.
The function blocks until the RMT peripheral finishes sending all LED data.
| new_state | Desired LED colours. |