ETrobocon2017 - 片山研究所モデルベース開発推進事業部
str
ev3-api
library
libcpp-ev3
src
Clock.cpp
[詳解]
1
//
2
// Clock.cpp
3
//
4
// Copyright (c) 2015-2016 Embedded Technology Software Design Robot Contest
5
//
6
7
#include "
Clock.h
"
8
using namespace
ev3api
;
9
10
11
//=============================================================================
12
// Constructor
13
Clock::Clock
(
void
)
14
:mStartClock(getTim())
15
{}
16
17
//=============================================================================
18
// reset system tick to 0
19
void
Clock::reset
(
void
)
20
{
21
mStartClock =
getTim
();
22
}
23
24
//=============================================================================
25
// get tick after app began
26
uint32_t
Clock::now
(
void
)
const
27
{
28
return
(
getTim
() - mStartClock);
29
}
30
31
uint32_t
Clock::getTim
()
32
{
33
SYSTIM time;
34
get_tim(&time);
35
// We're using a 32-bitter and can assume that we
36
// don't need to do any locking here.
37
return
static_cast<
uint32_t
>
(time);
38
}
ev3api
Definition:
Clock.h:12
ev3api::Clock::Clock
Clock(void)
Definition:
Clock.cpp:13
Clock.h
ev3api::Clock::now
uint32_t now(void) const
Definition:
Clock.cpp:26
ev3api::Clock::getTim
static uint32_t getTim()
Definition:
Clock.cpp:31
ev3api::Clock::reset
void reset(void)
Definition:
Clock.cpp:19
構築:
1.8.13