1
0
Fork 0
mirror of https://github.com/benkuper/FlowtoysConnectBridge synced 2025-02-22 14:54:02 +01:00
FlowtoysConnectBridge/LedManager.h
2021-01-11 10:23:15 +01:00

37 lines
698 B
C++

#pragma once
#include "FastLED.h"
#define DATA_PIN 25
#define CLOCK_PIN 26
#if VERSION == 1
#define NUM_LEDS 2
#elif VERSION == 2
#define NUM_LEDS 3
#endif
class LedManager
{
public:
CRGB leds[NUM_LEDS];
void init()
{
LEDS.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
LEDS.setBrightness(20);
FastLED.showColor(CRGB::Orange);
}
void setLed(int id, CRGB color, bool show = true)
{
if (id < 0 || id >= NUM_LEDS) return;
leds[id] = color;
if(show) LEDS.show();
}
void setAll(CRGB color)
{
for (int i = 0; i < NUM_LEDS; i++) leds[i] = color;
LEDS.show();
}
};