-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.h
144 lines (132 loc) · 3.37 KB
/
index.h
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
const char MAIN_page[] PROGMEM = R"=====(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>A Home Automation Temperature and Moisture Control System</title>
<style type="text/css">
button{
width:100px;
height: 50px;
background-color:palegoldenrod;
}
</style>
</head>
<summary> <b> A Home Automation Temperature and Moisture Control System<br>
</summary>
<hr color = pink>
<details class="menu" open>
<summary><b>Function 1: Contorl the LEDs<br>
</b>
</summary>
<p>
<button type="button" onClick='sendData(1)'>POWER ON </button><br>
<p>
<button type="button" onClick='sendData(0)'>POWER OFF </button>
<p>
<div>
POWER Status: <span id="LEDState">NA</span><br>
</div>
</details>
<hr color = pink>
<details class="menu" open>
<summary>
<b>Function 2: Real time temperature and moisture<br>
</b>
</summary>
<div>
<p style="color:blue;">Temperature: <span id = "TEMP">0</span> ℃<p></p>
<p style="color:blue;">Moisture: <span id = "HUM">0</span> %<p></p>
</div>
</details>
<hr color = pink>
<details class="menu" open>
<summary>
<b>Function 3: Change modes
</b>
</summary>
<p>
<button type="button" onclick='setflags(1)'>COOL</button>
<button type="button" onclick='setflags(2)'>HEAT</button>
<div>
MODE: <span id="MODEState">NA</span><br>
</div>
</details>
<hr color = pink>
<details class="menu" open>
<summary>
<b>Function 4: Temperature control
</b>
</summary>
<p>
<button type="button" onclick='setTemp(1)'>INCREASE</button>
<button type="button" onclick='setTemp(2)'>DECREASE</button>
<div>
Temperature: <span id="SetTemp">NA</span><br>
</div>
</details>
<hr color = pink>
<script>
function sendData(led) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("LEDState").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "setLED?LEDstate="+led, true);
xhttp.send();
}
function setflags(flags){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("MODEState").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "setMODE?MODEstate="+flags, true);
xhttp.send();
}
setInterval(function() {
getTemp();
getHum();
}, 2000);
function getTemp() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("TEMP").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "readTEMP", true);
xhttp.send();
}
function getHum() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("HUM").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "readHUM", true);
xhttp.send();
}
function setTemp(t){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("SetTemp").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "settemp?TEMPstate="+t, true);
xhttp.send();
}
</script>
</body>
</html>
)=====";