serial telnet
This commit is contained in:
@@ -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///////
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
#include "wifi_config.hpp"
|
||||
#include "SPIFFS.h"
|
||||
#include <ArduinoOTA.h>
|
||||
#include <TelnetStream2.h>
|
||||
#include "config_ota.hpp"
|
||||
TaskHandle_t TareaProcesador1;
|
||||
TaskHandle_t TareaProcesador2;
|
||||
void loop1(void *pvParameters);
|
||||
int anterior = millis();
|
||||
char sensorCadena[16];
|
||||
char sensorCadena[50];
|
||||
|
||||
|
||||
OpenTB6612FNG misMotores(0);
|
||||
@@ -21,6 +22,8 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
wifi();
|
||||
ota_init();
|
||||
TelnetStream2.begin();
|
||||
|
||||
SPIFFS.begin();
|
||||
init_sensores();
|
||||
|
||||
@@ -45,9 +48,9 @@ void loop()
|
||||
if (((millis() - anterior) > 100) && (nCliente > -1))
|
||||
{
|
||||
anterior = millis();
|
||||
|
||||
sprintf(sensorCadena, "%d",readSensors(0));
|
||||
webSocket.sendTXT(nCliente, sensorCadena);
|
||||
snprintf(sensorCadena, 50, "[%d,%d,%d,%d,%d]", readSensors(0), readSensors(1), readSensors(2),readSensors(3),readSensors(4));
|
||||
webSocket.sendTXT(nCliente, sensorCadena);
|
||||
TelnetStream2.println(sensorCadena);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user