Status is show during bootup and OTA by lighting some of the LEDs.
This commit is contained in:
		
							
								
								
									
										39
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								src/main.cpp
									
									
									
									
									
								
							| @@ -122,21 +122,56 @@ void setup_fastled() { | |||||||
| 	set_all_leds(CRGB::Black); | 	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; i<status; i++) { | ||||||
|  | 		if (i<corners.size()) { | ||||||
|  | 			corners[i]->set_color(color); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	for (int i=status; i<corners.size(); i++) { | ||||||
|  | 		corners[i]->set_color(CRGB::Black); | ||||||
|  | 	} | ||||||
|  | 	show_all(); | ||||||
|  | } | ||||||
|  |  | ||||||
| void setup() { | void setup() { | ||||||
| 	Serial.begin(74880); | 	Serial.begin(74880); | ||||||
| 	LOGln("ESPleaf starting."); | 	LOGln("ESPleaf starting."); | ||||||
|  |  | ||||||
| 	setup_layout(); | 	 | ||||||
| 	setup_fastled(); | 	setup_fastled(); | ||||||
|  | 	show_status(1); | ||||||
|  |  | ||||||
|  | 	setup_layout(); | ||||||
|  | 	show_status(2); | ||||||
|  |  | ||||||
| 	#ifdef TEST_MODE | 	#ifdef TEST_MODE | ||||||
| 		LOGln("TEST_MODE is active!"); | 		LOGln("TEST_MODE is active!"); | ||||||
| 	#else | 	#else | ||||||
| 		wifi_setup(); | 		wifi_setup(); | ||||||
|  |  | ||||||
|  | 		show_status(3); | ||||||
|  |  | ||||||
| 		mqtt_setup(); | 		mqtt_setup(); | ||||||
| 		ArduinoOTA.setHostname(OTA_HOSTNAME); | 		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(); | 		ArduinoOTA.begin(); | ||||||
| 	#endif |  | ||||||
|  |  | ||||||
|  | 		show_status(255); | ||||||
|  | 		delay(250); | ||||||
|  | 		show_status(0); | ||||||
|  | 	#endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void loop() { | void loop() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user