leOS - a simple taskmanager/scheduler

As mentioned elsewhere, leOS doesn't meet my requirements because it doesn't have a way to pass data to the callback. The C idiom I'm used to is to pass a void * to the scheduler with the function, then pass that on to the function. Given that this is an OOPL, one would expect to be able to pass a bound method, but C++ doesn't have those.

To see why, consider your 3-led example if you had this interface. You'd have the following changes:

typedef struct { byte led, status } myLed ;
myLed1 = {7, 0} ;
myLed2 = {8, 0} ;

in Setup:

   myOS.addTask(flashLed, (void *) &myLed1, 600) ;
   myOs.addtask(flashLed, (void *) &myLed2,  350) ;

And then the one flashLed function replacing the two you have now:

void flashLed(void* data) {
    myLed* led = (myLed *) status ;

   led->status ^= 1 ;
   digitalWrite(led->led, led->status) ;
}

While this case doesn't really save much code, note that you can add an LED by adding two lines of code instead of a new function. My use case was a bit more complicated, involving a task to bump the active row in an LED matrix using shift controllers.

One final note: a more OOP alternative would be to replace the function with an leOS_callBack object:

class leOS_callBack {
    public: void callBack(void) ;
} ;

Then, I'd use it by adding a callBack function to my method, and the library would invoke that method, giving me access to all the class variables that are currently causing me to curse C++.

Thanks,
<mike