TickerScheduler icon indicating copy to clipboard operation
TickerScheduler copied to clipboard

Examples of using TickerScheduler

Open rioan28 opened this issue 7 years ago • 4 comments

Hello all, could anyone be willing to provide me with a sample of how they used the TickerScheduler. I would really appreciate it.

Thank you in advance.

rioan28 avatar Dec 31 '17 08:12 rioan28

https://youtu.be/Au68C3I5B30

tretyakovsa avatar Oct 13 '19 13:10 tretyakovsa

Can someone explain the reason for this line in the example blink?

ts.add(0, 1000, [&](void *) { blink1(); }, nullptr, true);

[&](void *) { blink1(); } ?

ghost avatar Feb 06 '21 20:02 ghost

Hey @QuitButton!

It's called a lambda expression, this is how you define a function object inplace for TickerScheduler to execute. You can have multiple calls between the curly braces just like any other function: ts.add(0, 1000, [&](void *) { blink1(); blink2(); blink3(); }, nullptr, true);

Hope this clears things up :)

Here's some further reading: https://en.cppreference.com/w/cpp/language/lambda https://docs.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp?view=msvc-160

bozont avatar Feb 06 '21 21:02 bozont

Ok thanks. I'll be honest - I don't understand it, but I can at least use it to call a function, which is all I need.

ghost avatar Feb 07 '21 16:02 ghost