Handling MQTT commands formatted like HTTP requests.
This commit is contained in:
18
src/main.cpp
18
src/main.cpp
@ -14,10 +14,12 @@ std::list<Edge*> edges;
|
||||
std::vector<Corner*> corners;
|
||||
|
||||
CRGB leds[LED_COUNT];
|
||||
CRGB color = CRGB::Pink;
|
||||
|
||||
AnimationMode mode = AM_CORNERS;
|
||||
AnimationMode temp_mode;
|
||||
unsigned long temp_mode_until;
|
||||
int return_to_brightness = -1;
|
||||
|
||||
unsigned long last_loop = 0;
|
||||
|
||||
@ -136,6 +138,10 @@ void loop() {
|
||||
active_mode = temp_mode;
|
||||
} else {
|
||||
temp_mode_until = 0;
|
||||
if (return_to_brightness != -1) {
|
||||
FastLED.setBrightness(return_to_brightness);
|
||||
return_to_brightness = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,8 +186,18 @@ void loop() {
|
||||
}
|
||||
|
||||
if (millis() / 1000 > last_loop / 1000) {
|
||||
nodes[0]->blend_to(((millis() / 1000) % 2 == 0) ? CRGB::Black : CRGB::Orange, 0, 64);
|
||||
nodes[0]->blend_to(((millis() / 1000) % 2 == 0) ? CRGB::Black : color, 0, 64);
|
||||
}
|
||||
|
||||
} else if (active_mode == AM_OFF) {
|
||||
for(Node* node : nodes) {
|
||||
node->set_color(CRGB::Black);
|
||||
}
|
||||
} else { // This includes AM_ERROR
|
||||
for(Node* node : nodes) {
|
||||
node->set_color(CRGB::Black);
|
||||
}
|
||||
nodes[0]->set_color(CRGB::Red);
|
||||
}
|
||||
|
||||
last_loop = millis();
|
||||
|
Reference in New Issue
Block a user