#include "LedControl.h" #include "driver/rmt.h" #include "esp32_digital_led_lib.h" #include "Arduino.h" LedStrip::LedStrip(int numLeds, int pin) : numLeds_(numLeds), pin_(pin) { cfg = {.rmtChannel = 0, .gpioNum = pin, .ledType = LED_SK6812W_V1, .brightLimit = 24, .numPixels = numLeds}; strands[0] = &cfg; } void LedStrip::begin() { digitalLeds_initDriver(); gpioSetup(cfg.gpioNum, OUTPUT, LOW); int rc = digitalLeds_addStrands(strands, 1); if (rc) Serial.println("LEDs: Error during init"); } void LedStrip::clear() { digitalLeds_resetPixels(strands, 1); } void LedStrip::setColor(int led, int r, int g, int b, int w) { strands[0]->pixels[led] = pixelFromRGBW(r, g, b, w); } void LedStrip::transmit() { digitalLeds_drawPixels(strands, 1); } void LedStrip::setAll(int r, int g, int b, int w) { for (int i = 0; i < numLeds_; ++i) setColor(i, r, g, b, w); } void LedStrip::setRange(int begin, int end, int r, int g, int b, int w) { for (int i = begin; i < min(end, numLeds_); ++i) setColor(i, r, g, b, w); }