diff --git a/Grbl_Esp32/src/Pins/DebugPinDetail.cpp b/Grbl_Esp32/src/Pins/DebugPinDetail.cpp index 98d63f6e..3d924128 100644 --- a/Grbl_Esp32/src/Pins/DebugPinDetail.cpp +++ b/Grbl_Esp32/src/Pins/DebugPinDetail.cpp @@ -115,7 +115,7 @@ namespace Pins { // This method basically ensures we don't flood users: auto time = millis(); - if (uint32_t(_lastEvent + 1000) < time) { + if ((time - _lastEvent) > 1000) { _lastEvent = time; _eventCount = 1; return true; diff --git a/Grbl_Esp32/src/Pins/DebugPinDetail.h b/Grbl_Esp32/src/Pins/DebugPinDetail.h index 049c235e..b7e3db56 100644 --- a/Grbl_Esp32/src/Pins/DebugPinDetail.h +++ b/Grbl_Esp32/src/Pins/DebugPinDetail.h @@ -24,9 +24,9 @@ namespace Pins { class DebugPinDetail : public PinDetail { PinDetail* _implementation; - int _lastEvent; - int _eventCount; - bool _isHigh; + uint32_t _lastEvent; + int _eventCount; + bool _isHigh; struct CallbackHandler { void (*callback)(void* arg); diff --git a/Grbl_Esp32/src/WebUI/Commands.cpp b/Grbl_Esp32/src/WebUI/Commands.cpp index 91b59d04..41da82ad 100644 --- a/Grbl_Esp32/src/WebUI/Commands.cpp +++ b/Grbl_Esp32/src/WebUI/Commands.cpp @@ -41,10 +41,10 @@ namespace WebUI { * delay is to avoid with asyncwebserver and may need to wait sometimes */ void COMMANDS::wait(uint32_t milliseconds) { - uint32_t timeout = millis(); + uint32_t start_time = millis(); esp_task_wdt_reset(); //for a wait 0; //wait feeding WDT - while ((millis() - timeout) < milliseconds) { + while ((millis() - start_time) < milliseconds) { esp_task_wdt_reset(); } } diff --git a/Grbl_Esp32/src/WebUI/NotificationsService.cpp b/Grbl_Esp32/src/WebUI/NotificationsService.cpp index cfe37b61..124ff7cd 100644 --- a/Grbl_Esp32/src/WebUI/NotificationsService.cpp +++ b/Grbl_Esp32/src/WebUI/NotificationsService.cpp @@ -66,8 +66,8 @@ namespace WebUI { bool Wait4Answer(WiFiClientSecure& client, const char* linetrigger, const char* expected_answer, uint32_t timeout) { if (client.connected()) { String answer; - uint32_t starttimeout = millis(); - while (client.connected() && ((millis() - starttimeout) < timeout)) { + uint32_t start_time = millis(); + while (client.connected() && ((millis() - start_time) < timeout)) { answer = client.readStringUntil('\n'); log_d("Answer: %s", answer.c_str()); if ((answer.indexOf(linetrigger) != -1) || (strlen(linetrigger) == 0)) { diff --git a/Grbl_Esp32/src/WebUI/WebServer.cpp b/Grbl_Esp32/src/WebUI/WebServer.cpp index 63075df6..6664c3bd 100644 --- a/Grbl_Esp32/src/WebUI/WebServer.cpp +++ b/Grbl_Esp32/src/WebUI/WebServer.cpp @@ -887,8 +887,8 @@ namespace WebUI { _webserver->send(web_error, "text/xml", st); } - uint32_t t = millis(); - while (millis() - t < timeout) { + uint32_t start_time = millis(); + while ((millis() - start_time) < timeout) { _socket_server->loop(); delay(10); } @@ -1530,7 +1530,7 @@ namespace WebUI { } void Web_Server::handle() { - static uint32_t timeout = millis(); + static uint32_t start_time = millis(); COMMANDS::wait(0); if (WiFi.getMode() == WIFI_AP) { dnsServer.processNextRequest(); @@ -1541,11 +1541,11 @@ namespace WebUI { if (_socket_server && _setupdone) { _socket_server->loop(); } - if ((millis() - timeout) > 10000 && _socket_server) { + if ((millis() - start_time) > 10000 && _socket_server) { String s = "PING:"; s += String(_id_connection); _socket_server->broadcastTXT(s); - timeout = millis(); + start_time = millis(); } } @@ -1728,8 +1728,6 @@ namespace WebUI { AuthenticationIP* Web_Server::GetAuth(IPAddress ip, const char* sessionID) { AuthenticationIP* current = _head; //AuthenticationIP * previous = NULL; - //get time - //uint32_t now = millis(); while (current) { if (ip == current->ip) { if (strcmp(sessionID, current->sessionID) == 0) { @@ -1747,8 +1745,6 @@ namespace WebUI { AuthenticationLevel Web_Server::ResetAuthIP(IPAddress ip, const char* sessionID) { AuthenticationIP* current = _head; AuthenticationIP* previous = NULL; - //get time - //uint32_t now = millis(); while (current) { if ((millis() - current->last_time) > 360000) { //remove diff --git a/X86TestSupport/Stream.cpp b/X86TestSupport/Stream.cpp index 8eeb41fd..cf64aff3 100644 --- a/X86TestSupport/Stream.cpp +++ b/X86TestSupport/Stream.cpp @@ -36,7 +36,7 @@ int Stream::timedRead() { if (c >= 0) { return c; } - } while (millis() - _startMillis < _timeout); + } while ((millis() - _startMillis) < _timeout); return -1; // -1 indicates timeout } @@ -49,7 +49,7 @@ int Stream::timedPeek() { if (c >= 0) { return c; } - } while (millis() - _startMillis < _timeout); + } while ((millis() - _startMillis) < _timeout); return -1; // -1 indicates timeout } */