UdonLibrary
1.0.0
機械システム研究部 C++ ライブラリ
読み取り中…
検索中…
一致する文字列を見つけられません
Stopwatch.hpp
[詳解]
1
#pragma once
2
3
#ifdef ARDUINO
4
5
# include <Arduino.h>
6
7
namespace
Udon
8
{
10
class
Stopwatch
11
{
12
unsigned
long
times;
13
bool
stopFlag, resetFlag, timerState;
14
15
public
:
17
Stopwatch()
18
: times()
19
, stopFlag(false)
20
, resetFlag(false)
21
, timerState(false)
22
{
23
}
26
unsigned
long
getTime()
const
27
{
28
if
(resetFlag)
29
return
0;
30
if
(stopFlag)
31
return
times;
32
return
millis() - times;
// ms
33
}
35
void
start()
36
{
37
if
(not timerState)
38
times = millis();
39
timerState =
true
;
40
stopFlag =
false
;
41
resetFlag =
false
;
42
}
44
void
stop()
45
{
46
timerState =
false
;
47
if
(not stopFlag)
48
times = millis() - times;
49
stopFlag =
true
;
50
}
52
void
reset()
53
{
54
resetFlag =
true
;
55
}
56
};
57
58
}
// namespace Udon
59
#endif
Udon
Definition
Bit.hpp:12