-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_waterControl.ino
42 lines (39 loc) · 1.35 KB
/
02_waterControl.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
void checkWaterLevel(bool monitorEnable)
{
if (!startupComplete && startupStopwatch(_statupDelay, true) && waterHeight != 0)
resetHeight();
if (heightReadyToCheck && compareHeightStopWatch())
compareHeight();
if (pumpMode == CIRCULATION_ON_AUTO || pumpMode == CIRCULATION_ON_MANUAL)
autoCirculationStopWatch(false);
if (monitorEnable)
{
String messages[] = {"waterHeight", "pumpMode", "circulationActive", "heightReadyToCheck", "startupStopwatch(_statupDelay)", "startupComplete"};
unsigned long int data[] = {__floatToInt(waterHeight), __floatToInt(pumpMode), __floatToInt(circulationActive), __floatToInt(heightReadyToCheck), __floatToInt(startupStopwatch(_statupDelay, false)), __floatToInt(startupComplete)};
String format[] = {"cm", "bool", "bool", "bool", "f_bool", "bool"};
plotData("checkWaterLevel", messages, data, format, 6);
}
}
void resetHeight()
{
// Serial.println("\nRESETING HEIGHT\n");
lastHeightCheck = millis();
previousWaterHeight = waterHeight;
startupComplete = true;
heightReadyToCheck = true;
}
void compareHeight()
{
// Serial.println("\nCOMPARING HEIGHT\n");
if (waterHeight > previousWaterHeight + HEIGHT_INCREASE_VALUE)
{
circulationAutoEnable = true;
heightReadyToCheck = false;
autoCirculationStopWatch(true);
}
else
{
heightReadyToCheck = true;
resetHeight();
}
}