46 lines
1.0 KiB
C++
46 lines
1.0 KiB
C++
#include "leds.h"
|
|
|
|
static const char* TAG = "leds";
|
|
|
|
static led_strip_handle_t leds;
|
|
|
|
void init_leds() {
|
|
ESP_LOGI(TAG, "Initializing LEDs...");
|
|
|
|
led_strip_config_t strip_config = {
|
|
.strip_gpio_num = NEOPIXEL_PIN,
|
|
.max_leds = LED_COUNT,
|
|
.led_pixel_format = LED_PIXEL_FORMAT_GRB,
|
|
.led_model = LED_MODEL_WS2812
|
|
};
|
|
|
|
led_strip_rmt_config_t rmt_config = {
|
|
.clk_src = RMT_CLK_SRC_DEFAULT,
|
|
.resolution_hz = LED_STRIP_RMT_RES_HZ,
|
|
};
|
|
rmt_config.flags.with_dma = false;
|
|
|
|
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &leds));
|
|
|
|
ESP_LOGI(TAG, "LEDs initialized!");
|
|
}
|
|
|
|
void leds_set(IndicatorLED led, uint8_t r, uint8_t g, uint8_t b) {
|
|
led_strip_set_pixel(leds, i, i, LED_COUNT-i, 0)
|
|
}
|
|
|
|
void leds_flush() {
|
|
led_strip_refresh(leds);
|
|
}
|
|
|
|
void leds_clear()
|
|
{
|
|
led_strip_clear(leds);
|
|
}
|
|
|
|
void example_leds() {
|
|
for (int i = 0; i < LED_COUNT; i++) {
|
|
ESP_ERROR_CHECK(led_strip_set_pixel(leds, i, i, LED_COUNT-i, 0));
|
|
}
|
|
ESP_ERROR_CHECK(led_strip_refresh(leds));
|
|
} |