-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLightService.h
More file actions
54 lines (46 loc) · 1.5 KB
/
LightService.h
File metadata and controls
54 lines (46 loc) · 1.5 KB
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
enum HueColorType {
TYPE_HUE_SAT, TYPE_CT, TYPE_XY
};
enum HueAlert {
ALERT_NONE, ALERT_SELECT, ALERT_LSELECT
};
enum HueEffect {
EFFECT_NONE, EFFECT_COLORLOOP
};
struct HueLightInfo {
bool on = false;
int brightness = 0;
HueColorType type = TYPE_HUE_SAT;
int hue = 0, saturation = 0;
HueAlert alert = ALERT_NONE;
HueEffect effect = EFFECT_NONE;
unsigned int transitionTime = 800; // by default there is a transition time to the new state of 400 milliseconds
};
class aJsonObject;
bool parseHueLightInfo(HueLightInfo currentInfo, aJsonObject *parsedRoot, HueLightInfo *newInfo);
class LightHandler {
public:
// These functions include light number as a single LightHandler could conceivably service several lights
virtual void handleQuery(int lightNumber, HueLightInfo info, aJsonObject* raw) {}
virtual HueLightInfo getInfo(int lightNumber) {
HueLightInfo info;
return info;
}
};
// Max number of exposed lights is directly related to aJSON PRINT_BUFFER_LEN, 14 for 4096
#define MAX_LIGHT_HANDLERS 6
#define COLOR_SATURATION 255.0f
class ESP8266WebServer;
class LightServiceClass {
public:
LightHandler *getLightHandler(int numberOfTheLight);
bool setLightsAvailable(int numLights);
int getLightsAvailable();
bool setLightHandler(int index, LightHandler *handler);
void begin();
void begin(ESP8266WebServer *svr);
void update();
private:
int currentNumLights = MAX_LIGHT_HANDLERS;
};
extern LightServiceClass LightService;