This repository was archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChecks.ino
91 lines (67 loc) · 2.49 KB
/
Checks.ino
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
int checkTankLevel() {
updateSensors();
int WaterLevel;
if (HighLevelState == HIGH) {
WaterLevel = 255;
} else if (FloatSensorState == HIGH) {
WaterLevel = 250;
} else {
WaterLevel = 0;
}
return WaterLevel;
}
bool checkWaterConsumption() {
//checks current water consumption against daily target,
//if below target return true, if over target return false
bool returnValue;
if (targetVolume > waterChangeVol) {
returnValue = true;
} else {
returnValue = false;
waterChangeInProgress = false; //water change is completed
}
return returnValue;
}
bool checkInletPressure() {
//returns true if inlet pressure is good, false if pressure is low
bool returnValue = false;
// Serial.print("lastInletPres: ");
//Serial.println(lastInletPres);
//Serial.print("inletPres: ");
//Serial.println(inletPres);
if (inletPresEnable == false) { //if pressure switch is diabled
returnValue = true;
} else if (lastInletPres == HIGH && inletPres == LOW) { //if pressure falls
lastPresChangeTime = millis();
lastInletPres = inletPres;
returnValue = false;
//Serial.print("inlet pressure falls, return 0. Time lapsed: ");
//Serial.println(millis() - lastPresChangeTime);
} else if (lastInletPres == LOW && inletPres == HIGH ) { //if pressure rises
lastPresChangeTime = millis();
lastInletPres = inletPres;
//check if enough time has elapsed since the last time pressure fell
if ((millis() - lastPresChangeTime) > PressureChangeDelay) {
returnValue = true;
//Serial.print("Inlet pressure rise, return 1. Time lapsed: ");
//Serial.println(millis() - lastPresChangeTime);
} else {
returnValue = false;
//Serial.print("Inlet pressure rise, but not enough time lapsed, return 0. Time lapsed: ");
//Serial.println(millis() - lastPresChangeTime);
}
} else if (lastInletPres == HIGH && inletPres == HIGH ) { //pressure remains high
if ( (millis() - lastPresChangeTime) > PressureChangeDelay) {
returnValue = true;
//Serial.print("Inlet pressure remaining high, return 1. Time lapsed: ");
//Serial.println(millis() - lastPresChangeTime);
} else {
returnValue = false;
//Serial.print("Not enough time passed, return 0. Time lapsed: ");
//Serial.println(millis() - lastPresChangeTime);
}
}
//Serial.print("checkInletPressure: ");
//Serial.println(returnValue);
return returnValue;
}