Timer for accumulating 10 ms intervals that does not overflow after ~30 min

This class simply creates a timer that accumulates 10 millisecond intervals which does not overflow after about 30 min.

RunTimer.h

Committer:
jebradshaw
Date:
2016-07-11
Revision:
3:9efa965d2111
Parent:
2:67e16d628edc

File content as of revision 3:9efa965d2111:

/** RunTimer class.
 *  J. Bradshaw 20160519
 *  library for building a 10 millisecond running timer
 *
 * Example:
 * @code
 * #include "mbed.h"
 * #include "RunTimer.h"
 * 
 * Serial pc(USBTX,USBRX);
 * RunTimer runTime;
 * 
 * int main() {
 *     while(1){
 *          pc.printf("Time=day=%02d hour=%02d min=%02d sec=%02d ms=%02d \r\n", runTime.day,runTime.hour,runTime.min,runTime.sec,runTime.ms)
 *          wait(.02);
 *     }             
 * }
 * @endcode
 */
#ifndef MBED_RUNTIMER_H
#define MBED_RUNTIMER_H

#include "mbed.h"

class RunTimer{
    
public:    
    RunTimer();
    
    void timeAcc(void);
    void Reset(void);
    
    Ticker timer_10ms;          //Ticker for adding 10ms
    
    float ms_total;
    unsigned int ms;
    unsigned int sec;
    unsigned int min;
    unsigned int hour;
    unsigned int day;    
};

#endif