🪄 Formats LEDService
This commit is contained in:
@@ -9,15 +9,14 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WS2812_NUM_LEDS
|
#ifndef WS2812_NUM_LEDS
|
||||||
#define WS2812_NUM_LEDS 1+12
|
#define WS2812_NUM_LEDS 1 + 12
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define COLOR_ORDER GRB
|
#define COLOR_ORDER GRB
|
||||||
#define CHIPSET WS2811
|
#define CHIPSET WS2811
|
||||||
|
|
||||||
class LEDService
|
class LEDService {
|
||||||
{
|
private:
|
||||||
private:
|
|
||||||
TaskManager *_taskManager;
|
TaskManager *_taskManager;
|
||||||
|
|
||||||
unsigned long _lastUpdate = 0;
|
unsigned long _lastUpdate = 0;
|
||||||
@@ -29,19 +28,17 @@ private:
|
|||||||
int _brightness = 255;
|
int _brightness = 255;
|
||||||
int direction = 1;
|
int direction = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LEDService(TaskManager *taskManager) :
|
LEDService(TaskManager *taskManager) : _taskManager(taskManager) {
|
||||||
_taskManager(taskManager)
|
FastLED.addLeds<CHIPSET, WS2812_PIN, COLOR_ORDER>(leds, WS2812_NUM_LEDS).setCorrection(TypicalLEDStrip);
|
||||||
{
|
|
||||||
FastLED.addLeds<CHIPSET, WS2812_PIN, COLOR_ORDER>(leds, WS2812_NUM_LEDS).setCorrection( TypicalLEDStrip );
|
|
||||||
currentPalette = OceanColors_p;
|
currentPalette = OceanColors_p;
|
||||||
currentBlending = LINEARBLEND;
|
currentBlending = LINEARBLEND;
|
||||||
}
|
}
|
||||||
~LEDService(){}
|
~LEDService() {}
|
||||||
|
|
||||||
void begin(){}
|
void begin() {}
|
||||||
|
|
||||||
void loop(){
|
void loop() {
|
||||||
if (millis() - _lastUpdate < 1000 / 60) return;
|
if (millis() - _lastUpdate < 1000 / 60) return;
|
||||||
if (_brightness >= 200) direction = -5;
|
if (_brightness >= 200) direction = -5;
|
||||||
if (_brightness <= 50) direction = 5;
|
if (_brightness <= 50) direction = 5;
|
||||||
@@ -53,11 +50,10 @@ public:
|
|||||||
|
|
||||||
void fillFromPallette(uint8_t colorIndex) {
|
void fillFromPallette(uint8_t colorIndex) {
|
||||||
CRGB color = ColorFromPalette(currentPalette, colorIndex, _brightness, currentBlending);
|
CRGB color = ColorFromPalette(currentPalette, colorIndex, _brightness, currentBlending);
|
||||||
for( int i = 0; i < WS2812_NUM_LEDS; ++i) {
|
for (int i = 0; i < WS2812_NUM_LEDS; ++i) {
|
||||||
leds[i] = color;
|
leds[i] = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user