-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.html
63 lines (48 loc) · 1.79 KB
/
temp.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Temperature and humidity</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript" src="http://jsgauge.googlecode.com/svn/trunk/src/gauge.js"></script>
<script type="text/javascript" src="http://jsgauge.googlecode.com/svn/trunk/src/jquery.gauge.js"></script>
<script type="text/javascript">
$(document).ready(function(){
temperature = 0;
humidity = 20;
function readsensordata() {
$.getJSON('index.py?json=1', function(jd) {
temperature = parseFloat(jd.temperature);
humidity = parseFloat(jd.humidity);
// alert('hum: '+humidity+' temp: '+temperature);
$('#temperaturegauge').gauge('setValue', temperature);
$("#humiditygauge").gauge('setValue', humidity);
});
}
$("#temperaturegauge")
.gauge({
min: 0,
max: 50,
label: 'Temperature',
bands: [{color: "#ff0000", from: 40, to: 50}],
unitsLabel: '' + String.fromCharCode(186) + 'C'
})
.gauge('setValue', temperature);
$("#humiditygauge")
.gauge({
min: 20,
max: 90,
label: 'Humidity',
bands: [{color: "#ff0000", from: 70, to: 90}],
unitsLabel: '%'
})
.gauge('setValue', humidity);
readsensordata();
});
</script>
</head>
<body>
<canvas id="temperaturegauge" width="200" height="200"></canvas>
<canvas id="humiditygauge" width="200" height="200"></canvas>
</body>
</html>