GY-63_MS5611/libraries/StopWatch/StopWatch.h

46 lines
1.0 KiB
C
Raw Normal View History

2011-10-09 16:21:55 -04:00
#ifndef StopWatch_h
#define StopWatch_h
2013-08-17 10:44:07 -04:00
//
2011-10-09 16:21:55 -04:00
// FILE: StopWatch.h
// AUTHOR: Rob Tillaart
// PURPOSE: Simple StopWatch library for Arduino
// HISTORY: See StopWatch.cpp
// URL: http://www.arduino.cc/playground/Code/StopWatchClass
//
// Released to the public domain
//
2013-08-17 10:24:01 -04:00
#define STOPWATCH_LIB_VERSION "0.1.03"
2011-10-09 16:21:55 -04:00
2013-08-17 10:24:01 -04:00
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
2011-10-09 16:21:55 -04:00
2013-08-17 10:44:07 -04:00
class StopWatch
2011-10-09 16:21:55 -04:00
{
public:
2013-08-17 10:24:01 -04:00
enum State { RESET, RUNNING, STOPPED };
enum Resolution { MILLIS, MICROS, SECONDS };
StopWatch(enum Resolution res = MILLIS);
void start();
2013-08-17 10:44:07 -04:00
void stop();
2013-08-17 10:24:01 -04:00
void reset();
unsigned long value();
unsigned long elapsed() { return value(); };
bool isRunning();
enum State state();
enum Resolution resolution() { return _res; };
2011-10-09 16:21:55 -04:00
private:
2013-08-17 10:24:01 -04:00
enum State _state;
enum Resolution _res;
unsigned long _starttime;
unsigned long _stoptime;
unsigned long (*_gettime)(void);
static unsigned long seconds() { return millis()/1000; };
2011-10-09 16:21:55 -04:00
};
#endif
// END OF FILE