MTclock
Event management for Uno, Nano, Mega

Clock (metronme) to regularly call a function. Can also serve as a timer if you only ask one action.

Include to add

#include <MTobjects.h> // See http://arduino.dansetrad.fr/en/MTobjects

I strongly advise to leave the comment, if another person wanted to try the program, they would have a download link directly. This is valid for all the libraries you use.

Useful comments

milli_second
milli_seconds
action_and_stop
actions_and_stop

These comments are words that can be added anywhere and which are ignored by the compiler.

Constructor

Mtclock(interval_ms,
        onTimeFunction = NO_ACTION,
        numberOfActions = MT_INFINI,
        active = MT_ON);

Useful functions

void start(void);
void stop(void);
virtual void onTime(void);

start: activates the clock
stop: disable the clock
onTime: function to be overloaded called at the end of the count

Bonus functions

void setInterval_ms(unsigned long interval_ms);
void setInterval_ms();
unsigned long getInterval_ms();
void setOnTimeFunction(onTimeFunction);
void setOnTimeFunction();
void setNumberOfActions(unsigned long numberOfActions);
void setNumberOfActions();
unsigned long getNumberOfActions();
unsigned long getNumberOfActionsRemains();
boolean getActive();

setInterval_ms: change the basic time, 1s by default
setInterval_ms: without parameter puts 1s for the time base
getInterval_ms: returns the time interval in ms
setOnTimeFunction: changes the function called regularly
setOnTimeFunction: without parameter removes the call
setNumberOfActions: change the number of calls to make
setNumberOfActions: infinite if there are no parameters
getNumberOfActions: return the number of calls to be programmed
getNumberOfActionsRemains: return the number of calls that remains to be made
getActive: return true if the clock is active

Examples