WAKEUP - a simply library to manage counters

Hi there,

i’m sharing WAKEUP my first library here. It’s a simple way to manipulate counters and timers in your sketch.
(zip attached or https://github.com/brunocadet/WAKEUP)

Example of a counter : Blinking a LED

WAKEUP myLed;

void loop(){
if ( myLed.istime(500) ) digitalWrite( 13, !digitalRead(13) );  
}

Example of a timer

WAKEUP myTimer(30000);

void loop(){
if ( digitalRead(bouton) ) myTimer.go();
if ( myTimer.istime() ) Serial.print("DEBOUT LADANS!");  
}

Enjoy.

WAKEUP.zip (5.78 KB)

TIP: make the time related variables unsigned long instead of long ==> matches the values returned by millis() .
also for return values of some functions e.g.

long WAKEUP::remain(){
  return max(0, start+life-millis());
}
unsigned long WAKEUP::remain()
{
  unsigned long current = millis();
  if (current < start +life) return start + life - current;
  return 0; 
}