- Simple Tasks
- Multiple Tasks
- Communicating Tasks
- Communicating Values
- Synchronising Tasks
- Buffered Communication
- Multiple Senders
- Conditional Tasks
The clock component provides a millisecond resolution time source, which cycles through a 16-bit range of values from 0 to 32767.
The clock uses the Arduino's milliseconds function, which provides a 32-bit range of values, however this range is truncated to 16-bits for convenience, as all the other functions of the multitasking library are based on 16-bit integers. This imposes a 32.767 second limit on the maximum duration of pause actions.
The init_clock function is called when the multitasking library is initialised by the init_tasks function. It synchronises the clock with the internal Arduino's internal clock.
This function returns then clock time as a 16-bit value between 0 and 32767. It is used to record the starting_time of a pause action.
bool time_up(int start_time, int duration);
Given a start_time and a pause duration, the time_up function returns true if the clock has reached, or passed, the endpoint of the pause. It will correctly indicate when time is up even if the 16-bit clock has “wrapped round”, i.e, exceeded 32767 and resumed from 0, since the start_time.