Skip to content

Commit

Permalink
Fixed errors caused by const keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasfredericks committed Jul 1, 2015
1 parent 2342fab commit 7d73062
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
14 changes: 12 additions & 2 deletions Chrono.cpp
Expand Up @@ -86,14 +86,24 @@ bool Chrono::isRunning() const {

void Chrono::delay(unsigned long time) {
time += elapsed();
while (!passed(time));
while (!hasPassed(time));
}

unsigned long Chrono::elapsed() const {
return _offset + (_isRunning ? (_getTime() - _startTime) : 0);
}

bool Chrono::hasPassed(unsigned long timeout, bool restartIfPassed) const
bool Chrono::hasPassed(unsigned long timeout)
{
if (elapsed() >= timeout) {
return true;
}
else {
return false;
}
}

bool Chrono::hasPassed(unsigned long timeout, bool restartIfPassed)
{
if (elapsed() >= timeout) {
if (restartIfPassed)
Expand Down
5 changes: 3 additions & 2 deletions Chrono.h
Expand Up @@ -88,8 +88,9 @@ class Chrono
/// Returns the elapsed time since start (in milliseconds).
unsigned long elapsed() const;

/// Returns true iff elapsed time has passed given timeout.
bool hasPassed(unsigned long timeout, bool restartIfPassed=false) const;
/// Returns true if elapsed time has passed given timeout.
bool hasPassed(unsigned long timeout);
bool hasPassed(unsigned long timeout, bool restartIfPassed);

/// Returns true iff the chronometer is currently running.
bool isRunning() const;
Expand Down
12 changes: 11 additions & 1 deletion LightChrono.cpp
Expand Up @@ -46,7 +46,17 @@ unsigned long LightChrono::elapsed() const {
return (millis() - _startTime);
}

bool Chrono::hasPassed(unsigned long timeout, bool restartIfPassed) const
bool LightChrono::hasPassed(unsigned long timeout)
{
if (elapsed() >= timeout) {
return true;
}
else {
return false;
}
}

bool LightChrono::hasPassed(unsigned long timeout, bool restartIfPassed)
{
if (elapsed() >= timeout) {
if (restartIfPassed)
Expand Down
3 changes: 2 additions & 1 deletion LightChrono.h
Expand Up @@ -55,7 +55,8 @@ class LightChrono
unsigned long elapsed() const;

/// Returns true iff elapsed time has passed given timeout.
bool hasPassed(unsigned long timeout, bool restartIfPassed=false) const;
bool hasPassed(unsigned long timeout) ;
bool hasPassed(unsigned long timeout, bool restartIfPassed) ;
};

#endif
Expand Down

0 comments on commit 7d73062

Please sign in to comment.