Skip to content

Commit be9632e

Browse files
authored
Merge pull request #20 from luni64/staticFunctional
Switch from std::function to staticFunctional::function
2 parents bdc4bfc + fa7d53e commit be9632e

File tree

5 files changed

+349
-287
lines changed

5 files changed

+349
-287
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
#include "TeensyTimerTool.h"
3+
4+
using namespace TeensyTimerTool;
5+
6+
// Array of 10 tick timers
7+
PeriodicTimer timer[]{
8+
TCK, TCK, TCK, TCK, TCK,
9+
TCK, TCK, TCK, TCK, TCK};
10+
11+
void onTimer(int nr){
12+
Serial.printf("Timer #%d at %d\n", nr, millis());
13+
}
14+
15+
void setup(){
16+
// start all 10 timers with random period. Pass timer number to callback
17+
for (int i = 0; i < 10; i++)
18+
{
19+
timer[i].begin([i] { onTimer(i); }, random(100'000, 900'000));
20+
}
21+
}
22+
23+
void loop(){
24+
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11

22
#include "TeensyTimerTool.h"
3-
#include "pins.h"
4-
53
using namespace TeensyTimerTool;
6-
using namespace pins;
74

8-
pin<13> LED(OUTPUT);
95
OneShotTimer timer;
106

117
void setup()
128
{
13-
timer.begin([] { LED = LOW; });
9+
pinMode(LED_BUILTIN, OUTPUT);
10+
11+
timer.begin([] { digitalWriteFast(LED_BUILTIN, LOW); });
1412
}
1513

1614
void loop()
1715
{
18-
LED = HIGH;
19-
timer.trigger(25'000);
20-
delay(1'000);
16+
digitalWriteFast(LED_BUILTIN, HIGH); // switch on LED
17+
timer.trigger(25'000); // switch off after 25ms
18+
delay(1'000); // repeat every second
2119
}

examples/02_Advanced/UsingLambdas/pins.h

-253
This file was deleted.

0 commit comments

Comments
 (0)