-
Notifications
You must be signed in to change notification settings - Fork 5
/
ADDAC_GateDelay.cpp
executable file
·88 lines (45 loc) · 1.4 KB
/
ADDAC_GateDelay.cpp
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* Some hints about what this Class does!
*
*/
#include "ADDAC_GateDelay.h"
//-----------------------------------------------------------------------ADDAC EMPTY-----------------
/*! \brief Default construtor for ADDAC_GateDelay */
ADDAC_GateDelay::ADDAC_GateDelay(){ // INITIALIZE CLASS
}
/*! \brief Rise Time */
void ADDAC_GateDelay::GateDelayRise(){
time = millis();
}
/*! \brief Fall Time */
void ADDAC_GateDelay::GateDelayFall(){
timeFall = millis();
totalTime = timeFall - time;
}
// --------------------------------------------------------------------------- UPDATE -------------------------
//
/*! \brief Return true when GateDelay
\param _delay delay (milliseconds)
*/
bool ADDAC_GateDelay::update(float _delay){
if (time + _delay + totalTime < millis()){
state = 0;
}
else if (time + _delay < millis()) {
state = 1;
}
else {
state = 0;
}
Serial.print(" | ");
Serial.print(state);
if (oldState != state){
oldState = state;
return true;
}
else{
return false;
}
}
// --------------------------------------------------------------------------- END ----------------------------------
//