-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathstopWatch.cpp
More file actions
52 lines (47 loc) · 739 Bytes
/
stopWatch.cpp
File metadata and controls
52 lines (47 loc) · 739 Bytes
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
47
48
49
50
51
52
#include "dso_global.h"
#include "stopWatch.h"
#pragma once
static void tag();
/**
* return true if the time since the last ok() is greater than threshold
*/
bool StopWatch::elapsed(int threshold)
{
if(!armed)
{
armed=true;
mil=millis()&0xffff;
return false;
}
int delta=msSinceOk();
if (threshold<delta)
{
return true;
}
return false;
}
/**
*
* @return
*/
int StopWatch::msSinceOk()
{
newMil=millis()&0xffff;
int delta;
if(mil<=newMil)
{
delta=newMil-mil;
}else
{
delta=(0x10000+mil)-newMil;
}
return delta;
}
void StopWatch::ok()
{
mil=millis()&0xffff;
}
static void tag()
{
xAssert(0);
}