From c2c5c5bf763f153a10235ddc9a88a936829b4412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Petter=20=C3=85kesson?= Date: Thu, 9 Apr 2015 09:23:03 +0200 Subject: [PATCH] Added two comments to explain the while-loop in now() --- Time.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Time.cpp b/Time.cpp index 4cb01e7..b12baec 100644 --- a/Time.cpp +++ b/Time.cpp @@ -248,7 +248,9 @@ time_t sysUnsyncedTime = 0; // the time sysTime unadjusted by sync time_t now() { - while (millis() - prevMillis >= 1000){ + // calculate number of seconds passed since last call to now() + while (millis() - prevMillis >= 1000) { + // millis() and prevMillis are both unsigned ints thus the subtraction will always be the absolute value of the difference sysTime++; prevMillis += 1000; #ifdef TIME_DRIFT_INFO