ivanseidel / ArduinoThread

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

_onRun function pointer replaced by std::function #23

Closed Denages closed 7 years ago

Denages commented 7 years ago

Now we can use lambdas and method pointers in addition to function pointer as onRun action

Denages commented 7 years ago

Actual only for ESP8266

ivanseidel commented 7 years ago

Hi,

Do you still want to push this forward? If so, try to make it compatible with all the current boards ass well?

CAHEK7 commented 7 years ago

It doesn't seem like board-dependent feature. If toolchain (compiler and libraries) supports this C++ feature, it should work everywhere on any kind of board.

Denages commented 7 years ago

@CAHEK7 @ivanseidel The STL library is not included with AVR-GCC. Any ideas how to make it work?

fatal error: functional: No such file or directory

include

                  ^

compilation terminated. exit status 1 Error compiling for board Arduino/Genuino Uno.

Dionid commented 7 years ago

@Denages Have you found answer for this? I really need method to insert lambda functions and I used your way, but I can't be sure that it will work in every project. Maybe including https://github.com/maniacbug/StandardCplusplus will solve this problem?

CAHEK7 commented 7 years ago

Seems that library port could help. You can try use @Denages patch with https://github.com/maniacbug/StandardCplusplus and it should work.

But the patch won't be merged into master branch because it brings heavy dependencies.

Dionid commented 7 years ago

@CAHEK7 On NodeMCU LoLin v3 everything works fine even without StandardCplusplus (i didn't try on other ESP platforms). BUT on platforms like Arduino Nano (atmega328) / Uno even WITH StandardCplusplus it doesn't compile. Error is: "error: 'std::function' has not been declared"

I'm using PlatformIO. with this platformio.ini: [env:nanoatmega328] platform = atmelavr board = nanoatmega328 framework = arduino

My main aim is to have possibility to use lambda functions in Thread.onRun or some kind of function that will give me opportunity to predefine some arguments in function that will be used in Thread.onRun.

EmDash00 commented 5 years ago

@CAHEK7 On NodeMCU LoLin v3 everything works fine even without StandardCplusplus (i didn't try on other ESP platforms). BUT on platforms like Arduino Nano (atmega328) / Uno even WITH StandardCplusplus it doesn't compile. Error is: "error: 'std::function' has not been declared"

I'm using PlatformIO. with this platformio.ini: [env:nanoatmega328] platform = atmelavr board = nanoatmega328 framework = arduino

My main aim is to have possibility to use lambda functions in Thread.onRun or some kind of function that will give me opportunity to predefine some arguments in function that will be used in Thread.onRun.

I know this is old but I want to say that StandardCplusplus I haven't ever gotten to work with modern Arduino versions. A library called ArduinoSTL does though, and it contains <functional> much like StandardCPlusPlus