bolar_1 date 2026-7-1 d:/proc

This commit is contained in:
2026-11-27 17:44:38 +08:00
commit 0dbdfa57bc
890 changed files with 325428 additions and 0 deletions

35
main/led/single_led.h Normal file
View File

@@ -0,0 +1,35 @@
#pragma once
#include "led.h"
#include <driver/gpio.h>
#include <led_strip.h>
#include <esp_timer.h>
#include <mutex>
// WS2812 RGB LED — aligned with xiaozhi-server SingleLed (RMT driver)
class SingleLed : public Led {
public:
SingleLed(gpio_num_t gpio);
~SingleLed();
void SetState(LedState state) override;
private:
void SetColor(uint8_t r, uint8_t g, uint8_t b);
void TurnOn();
void TurnOff();
void StartContinuousBlink(int interval_ms);
void StartBreathing(int period_ms);
void OnBlinkTimer();
void OnBreathingTimer();
std::mutex mutex_;
led_strip_handle_t led_strip_ = nullptr;
esp_timer_handle_t blink_timer_ = nullptr;
esp_timer_handle_t breath_timer_ = nullptr;
LedState current_state_ = LedState::kOff;
uint8_t r_ = 0, g_ = 0, b_ = 0; // peak color for steady/blink/breath
int blink_counter_ = 0;
int breath_phase_ = 0;
int breath_steps_ = 0;
};