-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStopWatch.h
executable file
·46 lines (41 loc) · 1.01 KB
/
StopWatch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef StopWatch_h
#define StopWatch_h
//
// FILE: StopWatch.h
// AUTHOR: Rob Tillaart
// PURPOSE: Simple StopWatch library for Arduino
// HISTORY: See StopWatch.cpp
// URL: http://playground.arduino.cc/Code/StopWatchClass
//
// Released to the public domain
//
#define STOPWATCH_LIB_VERSION "0.1.03"
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class StopWatch
{
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; };
private:
enum State _state;
enum Resolution _res;
unsigned long _starttime;
unsigned long _stoptime;
unsigned long (*_gettime)(void);
static unsigned long seconds() { return millis()/1000; };
};
#endif
// END OF FILE