Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples of using TickerScheduler #15

Open
rioan28 opened this issue Dec 31, 2017 · 4 comments
Open

Examples of using TickerScheduler #15

rioan28 opened this issue Dec 31, 2017 · 4 comments

Comments

@rioan28
Copy link

rioan28 commented Dec 31, 2017

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.

@tretyakovsa
Copy link

@ghost
Copy link

ghost commented Feb 6, 2021

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

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

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

@bozont
Copy link

bozont commented Feb 6, 2021

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

@ghost
Copy link

ghost commented Feb 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants