Fixes for elapsed time support code. Do not count time when the argument of method is equal to 0.

pull/7/head
midilab 7 years ago
parent eabbc69a66
commit fd0420099a
  1. 20
      src/uClock.cpp

@ -295,22 +295,34 @@ void uClockClass::handleTimerInt()
// elapsed time support // elapsed time support
uint8_t uClockClass::getNumberOfSeconds(uint32_t time) 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) 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) 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) 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() uint32_t uClockClass::getNowTimer()

Loading…
Cancel
Save