Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MillisTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ void MillisTimer::run()
expired();
}

void MillisTimer::operator() (){
expired();
}

bool MillisTimer::expired()
{
Expand Down
1 change: 1 addition & 0 deletions MillisTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class MillisTimer
void reset();
bool expired();
void run();
void operator() ();

uint8_t ID;

Expand Down
13 changes: 13 additions & 0 deletions examples/MillisTimer_Example/MillisTimer_Example.pde
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ void myTimerFunction(MillisTimer &mt)
}


// declaration of timer using lambda expression (std=c++11)
MillisTimer timer2(500, [] (MillisTimer& tim) {
static bool ledState = false;
digitalWrite(LED_BUILTIN, ledState); // built in led 500ms blink
ledState ^= 1;
});


void setup()
{
Serial.begin(9600);
Expand All @@ -33,12 +41,17 @@ void setup()
timer1.expiredHandler(myTimerFunction);
timer1.setRepeats(5);
timer1.start();


pinMode(LED_BUILTIN, OUTPUT);
timer2.start();
}


void loop()
{
timer1.run();
timer2();

if (!timer1.isRunning())
{
Expand Down