-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPageIndex.h
201 lines (197 loc) · 6.1 KB
/
PageIndex.h
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
const char MAIN_page[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html {
font-family: Arial;
display: inline-block;
margin: 0px auto;
text-align: center;
}
.container {
height: 150px;
position: relative;
}
.centerA {
margin: 0;
position: absolute;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
}
.slidecontainer {
width: 100%;
}
.slider {
-webkit-appearance: none;
width: 75%;
height: 15px;
border-radius: 5px;
background: #f3f3f3;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
border-radius: 50%;
background: #FF0000;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 25px;
height: 25px;
border-radius: 50%;
background: #00FF00;
cursor: pointer;
}
.btn-group button {
background-color: #0000FF;
border: 5px solid grey;
color: white;
padding: 10px 10px;
cursor: pointer;
}
.btn-group:after { /* Clear floats (clearfix hack) */
content: "";
clear: both;
display: table;
}
.btn-group button:not(:last-child) {
border-right: none;
}
.btn-group button:hover {
background-color: #FF0000;
color: black;
}
</style>
</head>
<body style="background-color:grey;">
<h1>Azimuth/Inclination Control</h1>
<p>Command : <span id="command"></span></p>
<p>Azimuth Target : <span id="azvalue"></span></p>
<p>Current Azimuth : <span id="currazvalue"></span></p>
<div class="slidecontainer">
<input type="range" orient="vertical" min="0" max="360" value="0" class="slider" id="AzRange">
</div>
<p>Inclination Target : <span id="incvalue"></span></p>
<p>Current Inclination : <span id="currincvalue"></span></p>
<div class="slidecontainer">
<input type="range" orient="vertical" min="-55" max="55" value="0" class="slider" id="IncRange">
</div>
<p>Speed : <span id="spvalue"></span></p>
<div class="slidecontainer">
<input type="range" orient="vertical" min="0" max="100" value="100" class="slider" id="SpRange">
</div>
<div class="container">
<div class="centerA">
<div class="btn-group">
<button Home onclick="home()"> HOME </button>
<button Stop onclick= "stop()"> STOP </button>
<button Level onclick="level()"> LEVEL </button>
<button Forward onclick="forward()"> FORWARD </button>
</div>
</div>
</div>
<div class="container">
<div class="centerA">
<div class="btn-group">
<button GetPos onclick="donothing()"> Get Position </button>
<button SetAsHome onclick= "donothing()"> Set As Home </button>
<button HomingSequence onclick= "donothing()"> Homing Sequence </button>
</div>
</div>
</div>
<script>
function sendFlexData(packet, pos) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
}
};
if (packet == 1) { /* sending inclination */
xhttp.open("GET", "setINC?val="+pos, true);
}
if (packet == 2) { /* sending azimuth */
xhttp.open("GET", "setAZ?val="+pos, true);
}
if (packet == 3) { /* sending command. 0=stop 1=set zero 2=report pos */
xhttp.open("GET", "command?val="+pos, true);
}
if (packet == 4) { /* sending speed */
xhttp.open("GET", "setSP?val="+pos, true);
}
xhttp.send();
}
function getserverdata() {
var xhttp = new XMLHttpRequest();
command.innerHTML = "Retrieving server data";
}
function donothing() {
/* placeholder */
command.innerHTML = "placeholder, not implemented yet";
}
function home() {
command.innerHTML = "HOME";
incslider.value = 0;
incoutput.innerHTML = incslider.value;
sendFlexData(1, 0);
azslider.value = 0;
azoutput.innerHTML = azslider.value;
sendFlexData(2, 0);
}
function stop() {
command.innerHTML = "ALL STOP";
sendFlexData(3, 0); /* send command. position 0 = all stop */
}
function level() {
command.innerHTML = "Level Out";
incslider.value = 0;
incoutput.innerHTML = incslider.value;
sendFlexData(1, 0);
}
function forward() {
command.innerHTML = "Face Forward";
azslider.value = 0;
azoutput.innerHTML = azslider.value;
sendFlexData(2, 0);
}
var azslider = document.getElementById("AzRange");
var azoutput = document.getElementById("azvalue");
azoutput.innerHTML = azslider.value;
var incslider = document.getElementById("IncRange");
var incoutput = document.getElementById("incvalue");
incoutput.innerHTML = incslider.value;
var spslider = document.getElementById("SpRange");
var spoutput = document.getElementById("spvalue");
spoutput.innerHTML = spslider.value;
azslider.oninput = function() {
command.innerHTML = "Rotating";
azoutput.innerHTML = this.value;
sendFlexData(2, azoutput.innerHTML);
}
incslider.oninput = function() {
command.innerHTML = "Inclining";
incoutput.innerHTML = this.value;
sendFlexData(1, incoutput.innerHTML);
}
spslider.oninput = function() {
command.innerHTML = "Speed Change";
spoutput.innerHTML = this.value;
sendFlexData(4, spoutput.innerHTML);
}
</script>
</body>
</html>
)=====";