-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleds.h
51 lines (43 loc) · 999 Bytes
/
leds.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <FastLED.h>
#define NUM_TOTAL_LEDS 9
#define LED_PIN 2
#define BRIGHTNESS 64
#define NUM_INDICATOR_LEDS 3
#define NUM_BALL_LEDS 3
class Leds
{
private:
CRGB currentRGBIndicatorColor;
CHSV currentHSVIndicatorColor;
CRGB leds[NUM_TOTAL_LEDS];
public:
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_TOTAL_LEDS);
FastLED.setBrightness(BRIGHTNESS);
setAll(CRGB::Green);
delay(500);
setAll(CRGB::Black);
}
void setAll(CRGB c) {
for (int i = 0; i < NUM_TOTAL_LEDS; i++)
{
leds[i] = c;
}
FastLED.show();
}
void setIndicatorsBrightness(byte vals[]) {
for(int i=0; i<NUM_INDICATOR_LEDS; i++) {
CHSV c = currentHSVIndicatorColor;
c.val = vals[i];
leds[i] = c;
}
FastLED.show();
}
void setIndicatorsColor(CRGB c) {
currentRGBIndicatorColor = c;
currentHSVIndicatorColor = rgb2hsv_approximate(c);
}
void setIndicatorsColor(CHSV c) {
currentHSVIndicatorColor = c;
}
};