-
Notifications
You must be signed in to change notification settings - Fork 0
/
HeatingControl.ino
131 lines (85 loc) · 2.95 KB
/
HeatingControl.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//HeatingControl.ino
#define OFF_STYLE_CONTROL 0
#define ARDUINO_STYLE_CONTROL 1
#define MANUAL_STYLE_CONTROL 2
const char * const TEMP_CONTROL_STYLE[] =
{
"OFF",
"ARDUINO",
"MANUAL"
};
void controlHeating_loop(float namerenaTeplotaVBojleru)
{
if (MAIN_DEBUG) DEBUG_OUTPUT.println(" F:controlHeating_loop(namerenaTeplotaVBojleru): " + (String)namerenaTeplotaVBojleru);
if(boilerTempControlStyle_global != ARDUINO_STYLE_CONTROL)
{
if(RELAY_DEBUG) DEBUG_OUTPUT.println("RELAY_DEBUG: NO heating control on: " + (String)TEMP_CONTROL_STYLE[boilerTempControlStyle_global] + ", returning..");
return;
}
if (namerenaTeplotaVBojleru <= lowDropingTemp_global)
turnOnBoilerHeating();
if(namerenaTeplotaVBojleru >= topHeatingTemp_global)
turnOffBoilerHeating();
}
void turnOnBoilerHeating()
{
if(MAIN_DEBUG) DEBUG_OUTPUT.println(" F:turnOnBoilerHeating()");
if(boilerTempControlStyle_global == OFF_STYLE_CONTROL)
{
if(RELAY_DEBUG) DEBUG_OUTPUT.println("RELAY_DEBUG: NO heating control on: " + (String)TEMP_CONTROL_STYLE[boilerTempControlStyle_global] + ", returning..");
return;
}
else
{
if(setOpenBoilerHeatingRelay(false))
sendNodeStateUpdate("BoilerHeating_ON");
}
}
void turnOffBoilerHeating()
{
if(MAIN_DEBUG) DEBUG_OUTPUT.println(" F:turnOffBoilerHeating()");
if(boilerTempControlStyle_global == MANUAL_STYLE_CONTROL)
{
if(RELAY_DEBUG) DEBUG_OUTPUT.println("RELAY_DEBUG: NO heating control on: " + (String)TEMP_CONTROL_STYLE[boilerTempControlStyle_global] + ", returning..");
return;
}
else
if(setOpenBoilerHeatingRelay(true))
sendNodeStateUpdate("BoilerHeating_OFF");
}
void setTempControleStyle(byte newState) //1 - arduino(programatic), 2 - Manual(thermostat), 0 - Off eletkricity)
{
if(MAIN_DEBUG) DEBUG_OUTPUT.println(" F:setTempControleStyle(newState): " + (String)TEMP_CONTROL_STYLE[newState]);
if(newState != boilerTempControlStyle_global)
{
if(RELAY_DEBUG) DEBUG_OUTPUT.println("---->RELAY_DEBUG: Setting new style of TempControl: " + (String)TEMP_CONTROL_STYLE[newState]);
boilerTempControlStyle_global = newState;
sendNodeStateUpdate((String)"TempControl_" + (String)TEMP_CONTROL_STYLE[newState]);
if(newState == OFF_STYLE_CONTROL)
turnOffBoilerHeating();
if(newState == MANUAL_STYLE_CONTROL)
turnOnBoilerHeating();
}
else
if(RELAY_DEBUG) DEBUG_OUTPUT.println("---->RELAY_DEBUG: Already set ProgramaticTempControl: " + (String)TEMP_CONTROL_STYLE[newState]);
}
void cutOffBoilerElektricity()
{
if(MAIN_DEBUG) DEBUG_OUTPUT.println(" F:cutOffBoilerElektricity(): ");
if(boilerTempControlStyle_global != OFF_STYLE_CONTROL)
{
setTempControleStyle(OFF_STYLE_CONTROL);
}
}
byte getTempControleStyle()
{
return boilerTempControlStyle_global;
}
String getTempControleStyleStringName()
{
return TEMP_CONTROL_STYLE[boilerTempControlStyle_global];
}
bool isBoilerHeatingOn()
{
return !isBoilerHeatingRelayOpen();
}