-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
137 lines (132 loc) · 3.25 KB
/
index.html
File metadata and controls
137 lines (132 loc) · 3.25 KB
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>Balance_car</title>
<style>
#straight{
width:45%;
}
#data{
width:10%;
vertical-align:top;
}
#turn{
width:45%;
}
#forward{
width:0;
border:80px solid transparent;
border-bottom-color: blue;
}
#back{
width:0;
border:80px solid transparent;
border-top-color: green;
margin-top:20px;
}
#left{
width:0;
border:80px solid transparent;
border-right-color: red;
display: inline-block;
}
#right{
width:0;
border:80px solid transparent;
border-left-color: pink;
display: inline-block;
margin-left:20px;
}
</style>
</head>
<body>
<table width="100%">
<tr align="center">
<td id="straight">
<div>
<div id="forward" ontouchstart="moveDir(1)" ontouchend="moveDir(5)"></div>
<div id="back" ontouchstart="moveDir(2)" ontouchend="moveDir(6)"></div>
</div>
</td>
<td id="data">
<table style="border:1px solid #000;">
<tr>
<td>电压:</td>
<td id="voltage">3.99</td>
</tr>
<tr>
<td>角度:</td>
<td id="angle">0</td>
</tr>
</table>
</td>
<td id="turn">
<div>
<div id="left" ontouchstart="moveDir(3)" ontouchend="moveDir(7)"></div>
<div id="right" ontouchstart="moveDir(4)" ontouchend="moveDir(8)"></div>
</div>
</td>
</tr>
</table>
<video width="320" height="240" controls="controls" autoplay="autoplay">
<source src="./kun.mp4" type="video/mp4">
</video>
<script>
function showData(){
var volhttp = new XMLHttpRequest();
var anghttp = new XMLHttpRequest();
volhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("voltage").innerHTML =
this.responseText;
}
};
volhttp.open("GET", "/voltage", true);
volhttp.send();
anghttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("angle").innerHTML =
this.responseText;
}
};
anghttp.open("GET", "/angle", true);
anghttp.send();
}
function moveDir(dir){
switch(dir)
{
case 1:
document.getElementById("forward").style="border-bottom-color: black;";
break;
case 2:
document.getElementById("back").style="border-top-color: black;";
break;
case 3:
document.getElementById("left").style="border-right-color: black;";
break;
case 4:
document.getElementById("right").style="border-left-color: black;";
break;
case 5:
document.getElementById("forward").style="border-bottom-color: blue;";
break;
case 6:
document.getElementById("back").style="border-top-color: green;";
break;
case 7:
document.getElementById("left").style="border-right-color: red;";
break;
case 8:
document.getElementById("right").style="border-left-color: pink;";
break;
}
var movehttp = new XMLHttpRequest();
movehttp.open("GET", "/move?dir="+dir, true);
movehttp.send();
}
window.onload=setInterval(showData,200);
</script>
</body>
</html>