TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Scheduler Class Reference

Simple periodic task scheduler for embedded and Arduino environments. More...

#include <Scheduler.h>

Public Member Functions

void begin (uint16_t repeatMs, void(*cb)(void *), void *ref=nullptr)
 
void end ()
 
void setCallback (void(*cb)(void *))
 
void run ()
 
bool isActive () const
 
unsigned long millis ()
 

Protected Attributes

unsigned long start_time = 0
 
bool is_active_ = false
 
void(* callback )(void *) = nullptr
 
void * reference = nullptr
 
uint16_t repeatMs_
 

Detailed Description

Simple periodic task scheduler for embedded and Arduino environments.

This class provides a lightweight, non-blocking scheduler for executing a callback function at a fixed interval (in milliseconds). It is designed for use in embedded systems and Arduino sketches, where you want to perform periodic tasks (such as sensor readings, status updates, or control actions) without blocking the main loop.

Features

Usage Example

void myTask(void*) {}
Scheduler sched;
sched.begin(1000, myTask); // Call myTask every 1000 ms
// In your main loop:
while (true) {
sched.run();
// ... other code ...
}
Simple periodic task scheduler for embedded and Arduino environments.
Definition: Scheduler.h:57

Methods

Applications

Author
Phil Schatzmann

The documentation for this class was generated from the following file: