TDuino
Convenient functionality for Arduino
Static allocation of object memory

By default TTimer, TTimeline and TTimelineT uses dynamic memory allocation for the items / slots they hold. In some cases this may not be an ideal sollution and therefore it is possible to allocate the memory used by the objects in a static way.

You need to modify TDefs.h in the library folder and you must focus on the lines:

//#define TDUINO_TIMER_SIZE 10
//#define TDUINO_TIMELINE_SIZE 10

First you need to uncomment the line which belongs to the object you want to use static allocation for. Next you need to define how many items / slots that object should be able to hold - by default the value is 10, but you can modify this to suit your needs.

By doing this, all instances of the selected object will hold the number of slots / items specified with the define. The value passed to the objects constructor will be ignored.

//TDefs.h
#define TDUINO_TIMER_SIZE 5
//Sketch.ino
TTimer timer1(timerCallback, 10);
TTimer timer2(timerCallback, 8);

The code above will create two instances of TTimer, both able to hold 5 timers - even if another value is passed to the constructor!