-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_Loop.ino
More file actions
106 lines (94 loc) · 3.09 KB
/
3_Loop.ino
File metadata and controls
106 lines (94 loc) · 3.09 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
void loop() {
LoadOnOff.read();
if (LoadOnOff.changed()) {
Load == 0 ? LoadOn() : LoadOff();
}
SetButton.read();
if (SetButton.changed()) {
if (Mode == "Settings") { SaveSettings(); }
else if (Mode == "EditTransients") { SaveSettings(); }
else { SetLimits(); }
}
if ( Load == 1 && TransientsStatus == true ) {
SetTransients();
RunTransients();
}
// LIMITS
if ( temperature > temperatureLimit ||
power > powerLimit ||
current > currentLimit ||
voltage > voltageLimit ) {
LoadOff();
LimitWarning();
}
// Prevent Reading in Edit mode because of cursor behaviour
if ( Mode == "Read" || Mode == "TransientsMode" ) {
ReadCurrent();
ReadVoltage();
CalculatePower();
ReadTemperature();
}
CursorToggle.read();
if (Mode == "Settings") {
if ( CursorToggle.wasReleased() ) {
CursorCycle(3,currentLimitPos,voltageLimitPos,powerLimitPos,tempLimitPos);
}
} else if (Mode == "Read" && TransientsStatus == true) {
CursorToggle.wasReleased() ? EditTransients() : void();
} else if (Mode == "EditTransients") {
if ( CursorToggle.wasReleased() ) {
CursorCycle(2,transientFrequencyPos,transientMinPos,transientMaxPos,transientMaxPos);
}
}
ValueDown.read();
if (ValueDown.wasReleased()) {
if (Mode == "Settings") {
if (cycle == 0) {
DecreaseValue(currentLimitRef, 0.1, 0.1, 5, currentLimitPos);
} else if (cycle == 1) {
DecreaseValue(voltageLimitRef, 1, 1, 50, voltageLimitPos);
} else if (cycle == 2) {
DecreaseValue(powerLimitRef, 1, 1, 99, powerLimitPos);
} else if (cycle == 3) {
DecreaseValue(tempLimitRef, 1, 30, 60, tempLimitPos);
}
} else if (Mode == "EditTransients") {
if (cycle == 0) {
DecreaseValue(transientFrequencyRef, 10, 1, 10000, transientFrequencyPos);
} else if (cycle == 1) {
DecreaseValue(transientMinRef, 0.1, 0, 4, transientMinPos);
} else if (cycle == 2) {
DecreaseValue(transientMaxRef, 0.1, 0.1, 4, transientMaxPos);
}
}
}
ValueUp.read();
if (ValueUp.wasReleased()) {
if (Mode == "Settings") {
if (cycle == 0) {
IncreaseValue(currentLimitRef, 0.1, 0.1, 5, currentLimitPos);
} else if (cycle == 1) {
IncreaseValue(voltageLimitRef, 1, 1, 50, voltageLimitPos);
} else if (cycle == 2) {
IncreaseValue(powerLimitRef, 1, 1, 99, powerLimitPos);
} else if (cycle == 3) {
IncreaseValue(tempLimitRef, 1, 30, 60, tempLimitPos);
}
} else if (Mode == "EditTransients") {
if (cycle == 0) {
IncreaseValue(transientFrequencyRef, 10, 1, 10000, transientFrequencyPos);
} else if (cycle == 1) {
IncreaseValue(transientMinRef, 0.1, 0, 4, transientMinPos);
} else if (cycle == 2) {
IncreaseValue(transientMaxRef, 0.1, 0.1, 4, transientMaxPos);
}
} else if (Mode == "Read") {
ToggleTransientsMode();
}
}
currentMillisA = millis();
currentMillisV = millis();
currentMillisP = millis();
currentMillisT = millis();
currentMillis = millis();
}