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 12:38:38 -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://playground.arduino.cc/Code/StopWatchClass
2011-10-09 16:21:55 -04:00
//
2013-08-17 12:47:21 -04:00
// Released to the public domain
2011-10-09 16:21:55 -04:00
//
#define STOPWATCH_LIB_VERSION "0.1.03"
2011-10-09 16:21:55 -04:00
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
2011-10-09 16:21:55 -04:00
2013-08-17 12:38:38 -04:00
class StopWatch
2011-10-09 16:21:55 -04:00
{
public:
enum State { RESET, RUNNING, STOPPED };
enum Resolution { MILLIS, MICROS, SECONDS };
StopWatch(enum Resolution res = MILLIS);
void start();
void stop();
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:
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