#include "TimedEvents.h"

#define LED_ONE 6
#define LED_TWO 7
#define LED_THREE 8

// Timed Events can be global variables
TimedEvent t1;
TimedEvent t2;

TimedEvent t4;
TimedEvent t5;


void setup() {
  Serial.begin(9600);
  pinMode(LED_ONE, OUTPUT);
  pinMode(LED_TWO, OUTPUT);
  pinMode(LED_THREE, OUTPUT);
}

void loop() {
// The TimedEvent.every() function takes a float and returns true once every 'x' seconds
// The TimedEvent.everyMs() function takes an unsigned long and returns true once every 'x' milliseconds

  if (t1.everyMs(500)) // Repeat every 500 milliseconds
    digitalWrite(LED_ONE, !digitalRead(LED_ONE));

  if (t2.every(1.0f)) // Repeat every 1.0 second
    digitalWrite(LED_TWO, !digitalRead(LED_TWO));

  static TimedEvent t3; // TimedEvent can also be static local variables
  if (t3.every(1.5f)) // // Repeat every 1.5 seconds
    digitalWrite(LED_THREE, !digitalRead(LED_THREE));



// The TimedEvent.onceAt() function takes a float and returns true once only at 'x' seconds
// The TimedEvent.onceAtMs() function takes an unsigned long and returns true once only at 'x' milliseconds

  if (t4.onceAtMs(3000)) { // Once at 3000 milliseconds
    Serial.print("Here's a one time event at: ");
    Serial.println(millis());
  }

  if (t5.onceAt(5.0f)) { // Once at 5 seconds
    Serial.print("Here's a one time event at: ");
    Serial.println(millis());
  }

  static TimedEvent t6;
  if (t6.onceAtMs(7000)) { // Once at 3000 milliseconds
    Serial.print("Here's a one time event at: ");
    Serial.println(millis());
  }
}