ivanseidel / ArduinoThread

⏳ A simple way to run Threads on Arduino
MIT License
955 stars 196 forks source link

Calling the same callback for multiple thread and passing arguments to the thread #17

Closed NetForces closed 7 years ago

NetForces commented 7 years ago

Hi,

First awesome library. Kudos on the work.

Is is possible to have multiple threads calling the same callback ?

Is it also possible to pass arguments to the thread ? If so can you share an example ?

Thanks.

ivanseidel commented 7 years ago

Hi @NetForces , Thanks!

Yes, you can use multiple threads mapping to the same callback. However, there is no current way to pass on arguments to the threads.

But, you can create a custom thread that accepts a custom callback signature (with the parameters you want). Is your intention to identify the caller Thread? If so that's the best approach.

NetForces commented 7 years ago

Yup exactly I want to know the calling thread so that the behavior in the tread changes slightly instead of having 95% of the same code in unique callback function per thread.

Do you have an example n how I can create such a 'custom callback signature' ?

ivanseidel commented 7 years ago

Also, check what @tlextrait did with a Fork of this project. He managed to get callbacks with it: https://github.com/tlextrait/ArduinoThread

NetForces commented 7 years ago

Just so I don't need to fork your library I'll leave it as is right now. Thanks again for your time and effort.