-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathControlFunctions.ino
105 lines (91 loc) · 2.32 KB
/
ControlFunctions.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
void isrRemote() //interrupt routine for remote button press
{
//debounce the button
static unsigned long lastDebounceTime;
if ((millis() - lastDebounceTime) > 200) { //the delay (debounce) time, button is completley closed.
lastDebounceTime = millis();
//Button has been pressed, so toggle the remote status
remoteIsOn = !remoteIsOn;
lastPumpstop = 0L; //reset the huristic timers for pump restart so remote functions dont have delays.
lastPumpstart = 60000L;
}
}
boolean IsRemoteOnOff()
{
if (remoteIsOn)
{
return true; //remote is active
}
else
{
return false; //remote is not active
}
}
//control functions
void startAcidPump() {
// this should only run if filter pump is running
if (filterpumpRunning == true) {
//start Acid Pump;
digitalWrite (acidpumpPin, HIGH);
//Update Acid Runtime
acidpumpRunTime =(acidpumpRunTime+loopTime);
}
// dont want this as acid will run continuously if off peak hours.
if (filterpumpRunning == false) {
//stop Acid Pump;
digitalWrite (acidpumpPin, LOW);
}
}
void stopAcidPump() {
digitalWrite (acidpumpPin, LOW);
}
void startSolarPump() {
// Need a delay here so as to allow the filter pump to get the water flowing before starting the solar pump
SolarStartcount++;
if (SolarStartcount >= SolarStartDelay) {
if (solarpumpRunning == false) {
//start Solar Pump;
digitalWrite (solarpumpPin, HIGH);
solarpumpRunning = true;
}
}
}
void stopSolarPump() {
if (solarpumpRunning == true) {
// stop pump
digitalWrite(solarpumpPin, LOW);
//Reset the status and counters
solarpumpRunning = false;
SolarStartcount = 0;
}
}
void startFilterPump() {
if (filterpumpRunning == false) {
lastPumpstart = millis();
send(PumpCntrlmsg.set(1)); // Send pump status to MQTT
digitalWrite(filterpumpPin, HIGH);
digitalWrite(chlorinatorPin, HIGH);
filterpumpRunning = true;
}
}
void stopFilterPump() {
if (filterpumpRunning == true) {
// stop pump
lastPumpstop = millis();
send(PumpCntrlmsg.set(0)); // Send pump status to MQTT
digitalWrite(filterpumpPin, LOW);
digitalWrite(chlorinatorPin, LOW);
filterpumpRunning = false;
}
}
void doBeep() {
//Serial.print(bTime);
if (bTime == 20 ) { //this sets the time between beeps
digitalWrite(beepPin, HIGH);
delay(400);
digitalWrite(beepPin, LOW);
bTime = 0 ;
}
else
bTime = bTime++ ;
}