forked from evilgeniuslabs/tree-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFields.h
93 lines (74 loc) · 2.33 KB
/
Fields.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
uint8_t power = 1;
uint8_t brightness = brightnessMap[brightnessIndex];
//String setPower(String value) {
// power = value.toInt();
// if(power < 0) power = 0;
// else if (power > 1) power = 1;
// return String(power);
//}
String getPower() {
return String(power);
}
//String setBrightness(String value) {
// brightness = value.toInt();
// if(brightness < 0) brightness = 0;
// else if (brightness > 255) brightness = 255;
// return String(brightness);
//}
String getBrightness() {
return String(brightness);
}
String getPattern() {
return String(currentPatternIndex);
}
String getPatterns() {
String json = "";
for (uint8_t i = 0; i < patternCount; i++) {
json += "\"" + patterns[i].name + "\"";
if (i < patternCount - 1)
json += ",";
}
return json;
}
String getAutoplay() {
return String(autoplay);
}
String getAutoplayDuration() {
return String(autoplayDuration);
}
String getSolidColor() {
return String(solidColor.r) + "," + String(solidColor.g) + "," + String(solidColor.b);
}
String getCooling() {
return String(cooling);
}
String getSparking() {
return String(sparking);
}
String getSpeed() {
return String(speed);
}
String getTwinkleSpeed() {
return String(twinkleSpeed);
}
String getTwinkleDensity() {
return String(twinkleDensity);
}
FieldList fields = {
{ "power", "Power", BooleanFieldType, 0, 1, getPower },
{ "brightness", "Brightness", NumberFieldType, 1, 255, getBrightness },
{ "pattern", "Pattern", SelectFieldType, 0, patternCount, getPattern, getPatterns },
{ "speed", "Speed", NumberFieldType, 1, 255, getSpeed },
{ "autoplay", "Autoplay", SectionFieldType },
{ "autoplay", "Autoplay", BooleanFieldType, 0, 1, getAutoplay },
{ "autoplayDuration", "Autoplay Duration", NumberFieldType, 0, 255, getAutoplayDuration },
{ "solidColor", "Solid Color", SectionFieldType },
{ "solidColor", "Color", ColorFieldType, 0, 255, getSolidColor },
{ "fire", "Fire & Water", SectionFieldType },
{ "cooling", "Cooling", NumberFieldType, 0, 255, getCooling },
{ "sparking", "Sparking", NumberFieldType, 0, 255, getSparking },
{ "twinkles", "Twinkles", SectionFieldType },
{ "twinkleSpeed", "Twinkle Speed", NumberFieldType, 0, 8, getTwinkleSpeed },
{ "twinkleDensity", "Twinkle Density", NumberFieldType, 0, 8, getTwinkleDensity },
};
uint8_t fieldCount = ARRAY_SIZE(fields);