serial telnet

This commit is contained in:
2020-07-20 17:02:50 -05:00
parent f5254bdd71
commit a5b5950aad
4 changed files with 22 additions and 23 deletions

View File

@@ -29,7 +29,7 @@
<button class='buttons btn2' onclick='onDynamic()'>Dinámico</button>
<p id='txt1_id' class='buttons data'></p>
<p id='txt2_id' class='buttons data'></p>
<p id='distancia' class='buttons data'></p>
<p id='sensores' class='buttons data'></p>
</div>
<script>
@@ -39,8 +39,8 @@
var estatico = true, touchStart = false, mouseDown = false;
var angRad, angGrd, vectorHypot, speed;
var vector2 = function (x,y) {this.x= x || 0; this.y = y || 0;};
let distancia =0;
var distancia_label = document.getElementById('distancia');
let sensores =0;
var sensores_label = document.getElementById('sensores');
vector2.prototype = {
reset: function ( x, y ) {this.x = x; this.y = y; return this;},
copyFrom : function (v) {this.x = v.x; this.y = v.y; return this;},
@@ -53,11 +53,11 @@
connection.onerror = function (error) {console.log('WebSocket Error ', error);};
connection.onmessage = function (event) {
if(!isNaN(event.data))
//if(!isNaN(event.data))
distancia = parseInt(event.data,10)
distancia_label.innerHTML = 'Distancia<br/>'+distancia +" cm";
console.log('Server: ', distancia);
sensores = event.data//parseInt(event.data,10)
sensores_label.innerHTML = 'Sensores Linea<br/>'+sensores
console.log('Server: ', sensores);
};
///////CANVAS///////