-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeout.h
45 lines (29 loc) · 980 Bytes
/
timeout.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
#ifndef _TIMEOUT_H_
#define _TIMEOUT_H_
#include "application.h"
#include "rotary_coder.h"
typedef void (*CallbackType)(uint32_t);
class TimeOut
{
public :
TimeOut() { };
void Setup(uint32_t timeOut, uint32_t maxTimeOut, CallbackType callback = nullptr);
void CyclTask(int rotPos);
void newEvent(void) { _newEvent = true; }
bool getDispStatus(void) { return _switchOn; }
uint32_t Infinity(void) { return _maxTimeOut; }
int getPosMin(void) { return 5; }
int getPosMax(void) { return _maxTimeOut / 1000; }
int getPosDef(void) { return _setTimeOutDuration / 1000; }
private :
bool _newEvent;
bool _switchOn = true;
unsigned long _prevTime;
uint32_t _currentTime;
uint32_t _setTimeOutDuration;
uint32_t _maxTimeOut;
bool _setTimeOut;
int _posPrev;
CallbackType _callback;
};
#endif