-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLedControl.h
63 lines (50 loc) · 1.17 KB
/
LedControl.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
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef _LEDCONTROL_H_
#define _LEDCONTROL_H_
#define FASTLED_ESP8266_NODEMCU_PIN_ORDER
#include <FastLED.h>
#define LED_PIN 1
#define CHIPSET WS2812B
#define NUM_LEDS 8
#define MAX_BRIGHTNESS 255
// Default duration of fade in/out, in ms
#define FADE_DURATION 500
// HSV values of flame gradient values
#define RED 0
#define ORANGE 20
#define YELLOW 25
#define OFFLINE 0
enum class FlameMode
{
Flame,
Party,
Offline
};
enum class FadeState
{
On,
Off,
FadeIn,
FadeOut
};
class LedControl
{
public:
static void setup();
static void update();
static void setMode(FlameMode mode);
static void on();
static void off();
static void fadeIn(int delay = 0, int duration = FADE_DURATION);
static void fadeOut(int delay = 0, int duration = FADE_DURATION);
private:
static void resetFadeState(uint8_t brightness);
static uint8_t getBrightness();
static CRGB _leds[NUM_LEDS];
static CHSVPalette16 _palette;
static FlameMode _flameMode;
static FadeState _fadeState;
static int _fadeDuration;
static int _fadeDelay;
static long _fadeStart;
};
#endif