Closed crabel99 closed 3 years ago
Unfortunately, this prevents the use of # define
compilation options in Arduino IDE, so will not be merged.
Please see example 16 for the way to use TS in PlatformIO.
Now I understand how you have it set up. Instead of using the TaskScheduler.h
header, you use TaskSchedulerDeclarations.h
as the replacement header, and then create a single *.cpp and #include TaskScheduler.h
as the only line. Well played.
you use TaskSchedulerDeclarations.has the replacement header
Exactly, once you do that, you can extend your tasks cleanly and do it the OO way, including templating and pseudo-interfaces if needed. Here's a real-world example: https://github.com/GitMoDu/IValueReader/blob/master/src/Task/TemplateReaderTask.h
Including the class method definitions in the header file limits the extensibility of the library, by only allowing one
*.cpp
file to have access to theTaskScheduler.h
file. This prevents breaking the tasks up into smaller, isolated, and more manageable code blocks.My current project has three main libraries, one for data acquisition, one for a TFT display, and the other for the capacitive input. By breaking the code up this way I can create a singleton class wrapper for each of the three main functions with all of the tasks for the respective main functions neatly bundled together. To demonstrate the needed class structure, I posted a simple example of the
blink
sketch.I tested this library on a run of the mill
TaskScheduler
based sketch and it wasn't impacted.I thought the include guards would have isolated the class function definitions better, but my compiler did not seem to agree with me.