MTdoubleClock
Event management for Uno, Nano, Mega

Clock like metronome how can alternately call two functions..

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

MTdoubleClock(interval1_ms, interval2_ms,
              onTimeFunction1 = NO_ACTION,
              onTimeFunction2 = NO_ACTION,
              numberOfActions = MT_INFINI,
              active = MT_ON);

Useful functions

void start(void);
void stop(void);
virtual void onTime1(void);
virtual void onTime2(void);

start: activates the clock
stop: disable the clock
onTime1: an,d onTime2: function to be overloaded called at the end of the count

Bonus functions

void setInterval1_ms(unsigned long interval_ms);
void setInterval2_ms(unsigned long interval_ms);
void setInterval1_ms();
void setInterval2_ms();
unsigned long getInterval1_ms();
unsigned long getInterval2_ms();
void setOnTimeFunction1(onTimeFunction);
void setOnTimeFunction2(onTimeFunction);
void setOnTimeFunction1();
void setOnTimeFunction2();
void setNumberOfActions(unsigned long numberOfActions);
void setNumberOfActions();
unsigned long getNumberOfActions();
unsigned long getNumberOfActionsRemains();
boolean getActive();

setInterval1_ms, setInterval2_ms: change the basic time, 1s by default
setInterval1_ms, setInterval2_ms: without parameter puts 1s for the time base
getInterval1_ms, getInterval2_ms: returns the time interval in ms
setOnTimeFunction1, setOnTimeFunction2: changes the function called regularly
setOnTimeFunction1, setOnTimeFunction2: 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