Newer
Older
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
#ifndef CLOCK_H
#define CLOCK_H
/**@brief Interuption appelée régulièrement par le microcontroleur
* @see Clock::MS_PER_TICK
*/
extern "C" void SysTick_Handler();
class Clock
{
protected:
virtual void everyTick();
virtual void every5ms();
virtual void everySecond();
public:
static const unsigned long MS_PER_TICK = 5;
static const unsigned long MATCH_DURATION_MS = 90*1000;
static Clock* getInstance();
unsigned long elapsedSinceStartup() const;
void matchStart();
unsigned long elapsedSinceMatchStart() const;
bool isMatchStarted() const;
bool hasMatchEnded() const;
protected:
Clock();
private:
void tick();
friend void ::SysTick_Handler();
unsigned long m_tickCount;
unsigned long m_last5msTick;
unsigned long m_last1sTick;
unsigned long m_matchStartTime;
bool m_matchStarted;
};
#endif // CLOCK_H