bolar_1 date 2026-7-1 d:/proc
This commit is contained in:
35
main/led/single_led.h
Normal file
35
main/led/single_led.h
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user