-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
58 lines (53 loc) · 1.57 KB
/
index.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<meta name="viewport"
content="initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title></title>
<style>
.slider {
width: 220px;
height: 26px;
position: absolute;
left: 50%;
top: 50%;
margin: -13px 0 0 -110px;
}
</style>
</head>
<body>
<div class="slider">
<label for="duty">Brightness: </label>
<input id="duty" type="range" min="0" max="1023"
onchange="updatePwm(this.value)">
</div>
<script type="text/javascript"
src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
var lastUpdated = 1;
$.ajaxSetup({ timeout: 500 });
function updatePwm(newDuty) {
if (lastUpdated /*&& Date.now() - lastUpdated > 500*/) {
console.log('Setting brightness to ', newDuty);
$.get('/', {
fadeTo: newDuty
});
lastUpdated = Date.now()
}
}
function fetchStatus() {
$.get('/getPwmDuty', {}, function (data) {
$('#duty').val(data);
});
}
setInterval(fetchStatus, 10000);
fetchStatus();
</script>
</body>
</html>