A simplistic C++ class for embedded systems to manage tasks on the main loop.
LoopTicker provides a helper to manage asynchronous tasks in a simple way (no complex task scheduler, no hardware interrupts). It supports simple function calls and class methods.
- License: GPLv3
- Updates: https://github.com/Treboada/LoopTicker
- Issues: https://github.com/Treboada/LoopTicker/issues
- Contact: [email protected]
#include <LoopTicker.hpp>
// declare forwarding functions here and implement them where you want:
void btn_scan(LoopTicker* loop_ticker);
void LedBlinker::loopUpdate(const void* object_ptr, LoopTicker* loop_ticker);
// put the tasks to execute in this array
static const LoopTicker::Task tasks[] =
{
Task(btn_scan), // simple callback function
Task(&led1, led_blink), // instance and class method
Task(&led2, led_blink), // instance and class method
};
#define LOOP_TASKS_COUNTER (sizeof(tasks)/sizeof(tasks[0]))
// instance a LoopTicker scheduler
static LoopTicker task_ticker(tasks, LOOP_TASKS_COUNTER);
void setup()
{
}
void loop()
{
// execute the tasks by calling LoppTicker::doLoop()
task_ticker.doLoop();
}
- ArduinoBasic 3 Asynchronous tasks scheduled by LoopTicker.
- ObjectMethods Usage of object instances instead function callbacks.
On non-arduino frameworks, you can simulate the setup-loop pattern in this way:
#ifndef ARDUINO
int main(void)
{
setup();
for (;;) loop();
}
#endif
- C++ templates to avoid static class methods.
- Task sleeping (non-blocking lazy delay).
- Profiling tools.
- First release.
- Code documentation and README.
- Example with object methods (example 02)
- Task constructors.
- No need to declare function parameters if not used.
- Usage of POSIX time for Linux environments.