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

Is it possible to call a function with arguments? #4

Open
pfabri opened this issue Dec 27, 2016 · 4 comments
Open

Is it possible to call a function with arguments? #4

pfabri opened this issue Dec 27, 2016 · 4 comments

Comments

@pfabri
Copy link

pfabri commented Dec 27, 2016

In other words, must the callback function f be of the form f(void) or can it have arguments?

Many thanks for your help, neat library!

@Toshik
Copy link
Owner

Toshik commented Jan 4, 2017

For now there is no support for callback parameters.
But it is in my TODO list :)

@gmag11
Copy link

gmag11 commented Jan 4, 2017

If std library can be used it would be possible. Bind() function is your friend. I do not know it it is possible with Arduino, with esp8266 it is. Look at this code https://gist.github.com/gmag11/bd3f845c3eba2543df04d6de93f0474f
It is not exactly what you need but maybe you get what I mean.

Toshik added a commit that referenced this issue Feb 22, 2017
Example: t.add(0, 1000, [&](int*arg) { Serial.println((int)*arg); }, &arg);
@janmir
Copy link

janmir commented Mar 6, 2017

Thanks for this really neat & useful library, one thing though I noticed it has a little typo that causes a compile time error.
typedef std::function<void(void)> tscallback_t; should be typedef std::function<void(void*)> tscallback_t;

missing * on the param part.

@Toshik
Copy link
Owner

Toshik commented Mar 12, 2017

@janmir thanks for notice
e945e55 fix

dogoepp pushed a commit to dogoepp/TickerScheduler that referenced this issue Jun 25, 2018
Example: t.add(0, 1000, [&](int*arg) { Serial.println((int)*arg); }, &arg);
dogoepp added a commit to dogoepp/TickerScheduler that referenced this issue Jun 25, 2018
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

4 participants