-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflecha.html
108 lines (97 loc) · 3.67 KB
/
flecha.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
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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Página con Tres Columnas</title>
<style>
body {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-gap: 10px;
margin: 20px;
}
.columna {
padding: 10px;
border: 1px solid #ccc;
}
button {
width: 100%;
padding: 10px;
}
</style>
</head>
<body>
<div class="columna">
<input id="entrada1" type="text" value="1000" maxlength="6" >
</div>
<div class="columna">
<!-- Segundo Renglón -->
<button onclick="move_motors(1,1)">↑</button>
</div>
<div class="columna">
<input id="entrada2" type="text" value="1000" maxlength="6">
</div>
<div class="columna">
<!-- Tercer Renglón -->
<button onclick="move_motors(1,0)">←</button>
</div>
<div class="columna">
<button onclick="move_motors(0,0)">STOP</button>
</div>
<div class="columna">
<button onclick="move_motors(0,1)">→</button>
</div>
<div class="columna"></div>
<div class="columna">
<!-- Cuarto Renglón -->
<button onclick="move_motors(-1,-1)">↓</button>
</div>
<div class="columna"></div>
<div style="grid-column: span 3;">
<input type="text" id="commands" value="+600+10000+10000_+600-10000-10000_+200+3000-3000_+600+10000+10000_+600-10000-10000_+200+3000-3000_+600+10000+10000_+600-10000-10000_+200+3000-3000_" size="80"/>
<button onclick="draw()">Draw</button>
</div>
<div style="grid-column: span 3;">
<input type="text" id="commands" value="+600+10000+10000_+200+3000-3000_+600+10000+10000_+200+3000-3000_+600+10000+10000_+200+3000-3000_" size="80"/>
<button onclick="draw()">Draw</button>
</div>
<div style="grid-column: span 3;">
<input type="text" id="commands" value="+500+10000-0000_+500+000-10000_" size="80"/>
<button onclick="draw()">Draw</button>
</div>
<script>
function move_motors(x, y) {
const valorEntrada1 = parseFloat(document.getElementById('entrada1').value);
const valorEntrada2 = parseFloat(document.getElementById('entrada2').value);
if (isNaN(valorEntrada1) || isNaN(valorEntrada2)) {
console.error('Valores de entrada no son numéricos',document.getElementById('entrada1').value,document.getElementById('entrada2').value);
return;
}
console.log('Valores de entrada:', valorEntrada1, valorEntrada2);
// Use fetch to send coordinates to the server
fetch(`?x=${valorEntrada1 * x}&y=${valorEntrada2 * y}`)
.then(response => {
if (!response.ok) {
throw new Error('Error sending coordinates to the server');
}
console.log('Coordinates sent successfully');
})
.catch(error => console.error(error));
}
function draw() {
const commands = document.getElementById('commands').value;
console.log('Valores de comando:', commands);
// Use fetch to send coordinates to the server
fetch(`?command=${commands}`)
.then(response => {
if (!response.ok) {
throw new Error('Error sending coordinates to the server');
}
console.log('Commands sent successfully');
})
.catch(error => console.error(error));
}
</script>
</body>
</html>