WLED_DEBUG: fix for crash after LittleFS formating

This fixes a "division by zero" in WLED_DEBUG code.

LittleFS init seems to take some time, so we can arrive at "Loops/sec" with 0 loops executed --> crash.
This commit is contained in:
Frank 2022-10-04 13:50:01 +02:00
parent 78e0c3dcca
commit 7d5ce994ab

View File

@ -204,9 +204,11 @@ void WLED::loop()
DEBUG_PRINT(F("State time: ")); DEBUG_PRINTLN(wifiStateChangedTime);
DEBUG_PRINT(F("NTP last sync: ")); DEBUG_PRINTLN(ntpLastSyncTime);
DEBUG_PRINT(F("Client IP: ")); DEBUG_PRINTLN(Network.localIP());
if (loops > 0) { // avoid division by zero
DEBUG_PRINT(F("Loops/sec: ")); DEBUG_PRINTLN(loops / 30);
DEBUG_PRINT(F("UM time[ms]: ")); DEBUG_PRINT(avgUsermodMillis/loops); DEBUG_PRINT("/");DEBUG_PRINTLN(maxUsermodMillis);
DEBUG_PRINT(F("Strip time[ms]: ")); DEBUG_PRINT(avgStripMillis/loops); DEBUG_PRINT("/"); DEBUG_PRINTLN(maxStripMillis);
}
strip.printSize();
loops = 0;
maxUsermodMillis = 0;