#pragma once #include "core/runtime_state.h" #include #include #include #include #include namespace borla { class Ws2812Led final { public: Ws2812Led() = default; ~Ws2812Led(); bool Initialize(gpio_num_t gpio); void SetPattern(LedPattern pattern); private: enum class Animation : uint8_t { kOff, kSteady, kBlink, kBreathe, }; static void TimerCallback(void* context); void OnTimer(); void StopTimer(); void Render(uint8_t scale); void Configure(LedPattern pattern); std::mutex mutex_; led_strip_handle_t strip_ = nullptr; esp_timer_handle_t timer_ = nullptr; LedPattern current_pattern_ = LedPattern::kOff; Animation animation_ = Animation::kOff; uint8_t red_ = 0; uint8_t green_ = 0; uint8_t blue_ = 0; uint32_t period_ms_ = 0; uint32_t phase_ms_ = 0; }; } // namespace borla