forked from jjg/RESTduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restduino_control.html
68 lines (57 loc) · 3.58 KB
/
restduino_control.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
64
65
66
67
68
<html>
<head>
<title>RESDuino Controller</title>
</head>
<body>
<h3>digital pins PWM values:</h3>
<ol>
<li><input id="d1Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display1',this.value)" onMouseUp="sendToRestduino(1,this.value)">
<input id="display1" type="text" value="0"></li>
<li><input id="d2Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display2',this.value)" onMouseUp="sendToRestduino(2,this.value)">
<input id="display2" type="text" value="0"></li>
<li><input id="d3Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display3',this.value)" onMouseUp="sendToRestduino(3,this.value)">
<input id="display3" type="text" value="0"></li>
<li><input id="d4Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display4',this.value)" onMouseUp="sendToRestduino(4,this.value)">
<input id="display4" type="text" value="0"></li>
<li><input id="d5Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display5',this.value)" onMouseUp="sendToRestduino(5,this.value)">
<input id="display5" type="text" value="0"></li>
<li><input id="d6Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display6',this.value)" onMouseUp="sendToRestduino(6,this.value)">
<input id="display6" type="text" value="0"></li>
<li><input id="d7Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display7',this.value)" onMouseUp="sendToRestduino(7,this.value)">
<input id="display7" type="text" value="0"></li>
<li><input id="d8Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display8',this.value)" onMouseUp="sendToRestduino(8,this.value)">
<input id="display8" type="text" value="0"></li>
<li><input id="d9Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display9',this.value)" onMouseUp="sendToRestduino(9,this.value)">
<input id="display9" type="text" value="0"></li>
<li><input id="d10Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display10',this.value)" onMouseUp="sendToRestduino(10,this.value)">
<input id="display10" type="text" value="0"></li>
<li><input id="d11Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display11',this.value)" onMouseUp="sendToRestduino(11,this.value)">
<input id="display11" type="text" value="0"></li>
<li><input id="d12Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display12',this.value)" onMouseUp="sendToRestduino(12,this.value)">
<input id="display12" type="text" value="0"></li>
<li><input id="d13Input" type="range" min="0" max="255" value="0" onChange="updateDisplay('display13',this.value)" onMouseUp="sendToRestduino(13,this.value)">
<input id="display13" type="text" value="0"></li>
</ol>
<script>
function updateDisplay(control, value){
document.getElementById(control).value = value;
}
function sendToRestduino(pin, value){
// debug
console.log('sending ' + value + ' to pin ' + pin);
restduinoReq = new XMLHttpRequest();
restduinoReq.open('GET', 'http://10.0.1.53/' + pin + '/' + value, true);
restduinoReq.onreadystatechange = restduinoRes;
restduinoReq.send();
function restduinoRes(){
console.log('got response from restduino');
if(this.readyState == 4){
if(this.status == 200){
console.log(this.status);
}
}
}
}
</script>
</body>
</html>