led state applier
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#ifndef HARDWARE_LED_HPP
|
||||
#define HARDWARE_LED_HPP
|
||||
|
||||
#include "hardware.pb.h"
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
class HardwareLed {
|
||||
public:
|
||||
HardwareLed(uint8_t pin, uint8_t numPixels = 1);
|
||||
void begin();
|
||||
void end();
|
||||
void update();
|
||||
void set(const hardware_LedConfig& config);
|
||||
|
||||
private:
|
||||
void applyStatic(const hardware_StaticParams& params);
|
||||
void applyPulse(const hardware_PulseParams& params);
|
||||
void applyFade(const hardware_FadeParams& params);
|
||||
void applyFlicker(const hardware_FlickerParams& params);
|
||||
void setColor(uint32_t color, uint8_t brightness = 255);
|
||||
uint32_t lerpColor(uint32_t color1, uint32_t color2, float t);
|
||||
|
||||
Adafruit_NeoPixel _strip;
|
||||
hardware_LedConfig _currentConfig;
|
||||
unsigned long _startTime;
|
||||
uint8_t _pulseState;
|
||||
unsigned long _lastPulseTime;
|
||||
uint8_t _fadeIndex;
|
||||
unsigned long _lastFadeTime;
|
||||
uint32_t _fadeCurrentColor;
|
||||
uint32_t _fadeTargetColor;
|
||||
float _fadeProgress;
|
||||
unsigned long _fadeStartTime;
|
||||
bool _isActive;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user