TimeCall Librairie

Hi, i started a small project, TimeCall, It give you the possibility of calling up to 16 (configurable) program at different time interval.

Lets say that you would like to call a function every 10ms and another one at every 26ms Then this is for you.

You can also give parameter to those function. It use the timer 2, but the good thing is that you can call a lot of function with different interval using only a single timer in the AtMega.

The resolution is 1ms for now, I have test that with Arduino21 i would like your feedback on this. BTW i got help from a lot of people getting this to work, thanks to you all.

Patgadget

http://www.patgadget.com/files/TimeCall/TimeCallRev1.0.zip

Good job! Two quick comments: 1] if you clear the internal info array when an object is created you could possibly get some frustrated users if

//somewhere in code:
if (needATimedCallForSomeTime) {
  TimeCall tempTimeCall;
  tempTimeCall.go(...);
  doSomethingWhileTimeCallExecutes();
}

One scenario could be to continously check for an available connection or something like that.

2] You have no way of clearing a once set go, so you are restricted to 16 calls to go, and not 16 simulatanous scheduled calls (well, that to, but the main restriction is that after 16 calls the 17th would fail even if the object that 'owned' the timed call is now out of scope aka dead.

One last comment, have you seen my TimedAction library?

I have to say that the idea of being able to pass down arguments was a good one. Never thought about that.

Thanks, No i did not check your librairie, Wow well build. i am more a Hardware guy, got help from a friend (software) that was curious about the Arduino. He did most of the class part, i did some code that work (a few post earlier) but nothing like the one i got now.

Quote: Two quick comments: 1] if you clear the internal info array when an object is created you could possibly get some frustrated users if

I don't get your question?, why would i clear the internal info? i do not clear the info array (as i recall)

Quote: 2] You have no way of clearing a once set go, so you are restricted to 16 calls to go, and not 16 simulatanous scheduled calls (well, that to, but the main restriction is that after 16 calls the 17th would fail even if the object that 'owned' the timed call is now out of scope aka dead.

You are right for the not clearing a once set up, i could add a .stop to the .go . For the 16 call, i limited becose i did not want to take to much ram. If i had a way to kill a call then a 17 call would find its way (check if NULL in the info[] in the .cpp)

But after seeing you code do you think i should keep going or just use you're code instead? You could add the argument in you librairie? Is your code using a large memory chunk?

Thanks for your comments and feel free to use anything that you like in my code.

Patgadget

TimeCall::TimeCall()
{
      _init = false;
      
      for(int cnt=0; cnt < 16; ++cnt)
      {
            info[cnt]._callthis  = NULL;
      }
}

This clears the value of all callthis callbacks.
Also, if you hardcode the boundary (16) you’ll be suprised later when you change the max call constant. :slight_smile:

My library does not depend on a timer, it uses less RAM (even with 16 active instances) but it does not currently support passing parameters down to the function. I could add that feature, but I’m not sure it’s needed. I would rather have the user add three wrapping functions that passes the parameters to specifying functions along the lines of:

void blink1() { blink(1); }
void blink2() { blink(2); }

I do not want to say that you should abandon your library, I just wanted to share my thoughts :slight_smile:

Thanks, i will check out my error! I will start trying your Librairie. I did not now that the playground was filled with a lot of librairies I will check this before trying to code something that already work ;-)

Again Thanks a lot. Patgadget