From 808112ebb03a3b017d85d6fed71f677951307191 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Sun, 10 Jan 2021 16:29:30 +0100 Subject: [PATCH] Status is show during bootup and OTA by lighting some of the LEDs. --- src/main.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a0a7710..045e23a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,21 +122,56 @@ void setup_fastled() { set_all_leds(CRGB::Black); } +void show_all() { + for(Node* node : nodes) { + node->draw(); + } + FastLED.show(); +} + +void show_status(uint8_t status, CRGB color=CRGB::Green) { + for (int i=0; iset_color(color); + } + } + for (int i=status; iset_color(CRGB::Black); + } + show_all(); +} + void setup() { Serial.begin(74880); LOGln("ESPleaf starting."); - setup_layout(); + setup_fastled(); + show_status(1); + + setup_layout(); + show_status(2); + #ifdef TEST_MODE LOGln("TEST_MODE is active!"); #else wifi_setup(); + + show_status(3); + mqtt_setup(); ArduinoOTA.setHostname(OTA_HOSTNAME); + ArduinoOTA.onProgress([&](unsigned int progress, unsigned int total){ + uint8_t count = progress * corners.size() / total; + show_status(count, CRGB::Blue); + }); + ArduinoOTA.onEnd([](){ show_status(0); }); ArduinoOTA.begin(); + + show_status(255); + delay(250); + show_status(0); #endif - } void loop() {