#pragma once #include #include #include #include "hardware/dma.h" #include "hardware/pio.h" struct RGB; class WS2812B { public: WS2812B(uint16_t num_leds, uint pin, uint strip_index, float brightness = 1.0f); ~WS2812B(); WS2812B(const WS2812B&) = delete; WS2812B& operator=(const WS2812B&) = delete; void fill(RGB color); void set(uint16_t index, RGB color); void show(const uint8_t* buffer = nullptr, size_t offset = 0); void prepare_show(const uint8_t* buffer = nullptr, size_t offset = 0); void trigger(); bool busy() const; uint16_t num_leds; float brightness; std::vector buffer; int dma_channel = -1; PIO pio = pio0; uint sm = 0; private: uint pin_; };