From fd0420099acc1a0874cf11587ae72d0ba0080365 Mon Sep 17 00:00:00 2001 From: midilab Date: Mon, 4 Dec 2017 09:22:22 -0200 Subject: [PATCH] Fixes for elapsed time support code. Do not count time when the argument of method is equal to 0. --- src/uClock.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/uClock.cpp b/src/uClock.cpp index d769f2b..7274fde 100755 --- a/src/uClock.cpp +++ b/src/uClock.cpp @@ -295,22 +295,34 @@ void uClockClass::handleTimerInt() // elapsed time support uint8_t uClockClass::getNumberOfSeconds(uint32_t time) { - return ((millis() - time) / 1000) % SECS_PER_MIN; + if ( time == 0 ) { + return time; + } + return ((_timer - time) / 1000) % SECS_PER_MIN; } uint8_t uClockClass::getNumberOfMinutes(uint32_t time) { - return (((millis() - time) / 1000) / SECS_PER_MIN) % SECS_PER_MIN; + if ( time == 0 ) { + return time; + } + return (((_timer - time) / 1000) / SECS_PER_MIN) % SECS_PER_MIN; } uint8_t uClockClass::getNumberOfHours(uint32_t time) { - return (((millis() - time) / 1000) % SECS_PER_DAY) / SECS_PER_HOUR; + if ( time == 0 ) { + return time; + } + return (((_timer - time) / 1000) % SECS_PER_DAY) / SECS_PER_HOUR; } uint8_t uClockClass::getNumberOfDays(uint32_t time) { - return ((millis() - time) / 1000) / SECS_PER_DAY; + if ( time == 0 ) { + return time; + } + return ((_timer - time) / 1000) / SECS_PER_DAY; } uint32_t uClockClass::getNowTimer()