TimeCommander.cpp
bool TimeCommander::countTo(short int timerID, unsigned int seconds, bool reset)
{
  this->keepTime();

  // max seconds 65534
  if (seconds >= 65535) {
    seconds = 65534;
  }

  // required time reached?
  if (timers[timerID] >= seconds) {
    if (reset) {
      // we want to trigger the event (return true) and start over
      timers[timerID] = 0;
      return true;
      
    } else {
      // time reached, decide if this was already triggered
      if (timers[timerID] == 65535) {
        // was already triggered
        return false;
      } else {
        // set a triggered flag and return true
        timers[timerID] = 65535;
        return true;
      }
      
    }

  } else {
    // time not reached
    return false;
  }

}
// return true if a value was reached, no reset the timer unless requested
return true if a value was reached, no reset the timer unless requested
return true if a value was reached no reset the timer unless requested
bool TimeCommander::countTo(short int timerID, unsigned int seconds, bool reset)
{
  this->keepTime();
  if (seconds >= 65535) {
    seconds = 65534;
  }
  if (timers[timerID] >= seconds) {
    if (reset) {
      timers[timerID] = 0;
      return true;
    } else {
      if (timers[timerID] == 65535) {
        return false;
      } else {
        timers[timerID] = 65535;
        return true;
      }
    }
  } else {
    return false;
  }
}
bool TimeCommander :: countTo ( short int timerID , unsigned int seconds , bool reset ) { this -> keepTime ( ) ; if ( seconds >= 65535 ) { seconds = 65534 ; } if ( timers [ timerID ] >= seconds ) { if ( reset ) { timers [ timerID ] = 0 ; return true ; } else { if ( timers [ timerID ] == 65535 ) { return false ; } else { timers [ timerID ] = 65535 ; return true ; } } } else { return false ; } }
return true if a value was reached, no reset the timer unless requested
return true if a value was reached no reset the timer unless requested
// max seconds 65534 // required time reached? // we want to trigger the event (return true) and start over // time reached, decide if this was already triggered // was already triggered // set a triggered flag and return true // time not reached