-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_json.js
51 lines (48 loc) · 1.26 KB
/
script_json.js
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
var gauge2 = Gauge(
document.getElementById("gauge2"), {
max: 100,
dialStartAngle: 180,
dialEndAngle: 0,
value: 50
}
);
var gauge3 = Gauge(
document.getElementById("gauge3"), {
max: 100,
value: 50
}
);
function LerSensores(){
var request = new XMLHttpRequest();
request.onreadystatechange = function(){
if(this.readyState == 4){
if(this.status == 200){
if(this.responseText != null){
var dados = json.parse(this.responseText);
alert(dados.gt)
if (dados.gt < 100 && dados.gt > 0){
gauge3.setValueAnimated(dados.gt,1);
};
if (dados.gh < 100 && dados.gh > 0){
gauge2.setValueAnimated(dados.gh,1);
};
if(dados.led == 0){
document.getElementById("botao1").style.backgroundColor = "#ff704d";
}
else{
document.getElementById("botao1").style.backgroundColor = "#ADFF85";
}
}
}
}
}
request.open("GET", "http://172.32.0.100/dht/0/r/", true);
request.send(null);
setTimeout(LerSensores,1000 * 50);
}
function BotaoCarga1(){
var request = new XMLHttpRequest();
request.open("GET", "http://172.32.0.100/led/2/s", true);
request.send(null);
LerSensores();
}