-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSWLogic.h
73 lines (52 loc) · 1.19 KB
/
SWLogic.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef SWLogic_H
#define SWLogic_H
class SWTimer //Arduino-based timer
{
public:
SWTimer();
public:
//Returns true if t - t0 > timer, false otherwise. If no timer is running, returns false
bool value();
//Starts the n-miliseconds timer if set is true
void timer( bool set, long time );
//Combination of the above: Start a n-miliseconds timer and return true if t - t0 > timer
bool onDelay( bool set, long time );
private:
unsigned long _start;
long _time;
};
class SWKeep //Simple state register
{
public:
SWKeep() : _state(false) {};
public:
//Save the state or reset the stored value, returns the stored value
bool keep( bool set, bool reset );
//Return the value of the register
inline bool value() { return _state; }
private:
bool _state;
};
class SWDifu
{
public:
SWDifu() : _state(false) {};
public:
bool difU( bool set );
inline bool value() { return _state; }
private:
bool _pre;
bool _state;
};
class SWDifd
{
public:
SWDifd() : _state(false) {};
public:
bool difD( bool set );
inline bool value() { return _state; }
private:
bool _pre;
bool _state;
};
#endif