Ok Surbyte, disculpas, tienes razon.
A continuacion el codigo:
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
//#####################################//
const char* ssid = "HABITACION";
const char* password = "Hotel2017";
String readString;
char c;
String acao;
String txtLed = "AGUARDANDO.....";
String velLed;
int velLedInt;
WiFiServer server(80);
//#####################################//
//#####################################//
int pinCS = 5;
int numberOfHorizontalDisplays = 4;
int numberOfVerticalDisplays = 1;
String tape = "AGUARDANDO.....";
int wait = 50; // Em milessegundos.
int spacer = 1;
int width = 5 + spacer;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
//#####################################//
void setup() {
Serial.begin(115200);
delay(10);
Serial.print("Conectando a la red: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi Conectada");
server.begin();
Serial.println("Servidor iniciado!");
Serial.print("Direccion IP: ");
Serial.println(WiFi.localIP());
//#####################################//
matrix.setIntensity(15);
matrix.setRotation(0, 1);
matrix.setRotation(3, 1);
matrix.setRotation(1, 1);
matrix.setRotation(2, 1);
//#####################################//
}
void loop() {
for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ ) {
matrix.fillScreen(LOW);
//####################################################################################//
WiFiClient client = server.available();
if (client) {
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 100) {
readString += c;
}
if (c == '\r') {
if(readString.indexOf("?") > 0){
//##SEPARANDO EL VALOR DE LA VARIABLE ACAO##//
int acaoI = readString.indexOf("?a=") + 3;
int acaoF = readString.indexOf("&txt=");
acao = readString.substring(acaoI,acaoF);
Serial.print("ACAO: ");
Serial.println(acao);
//##SEPARANDO EL VALOR DE LA VARIABLE TXTLED##//
int txtLedI = readString.indexOf("&txt=") + 5;
int txtLedF = readString.indexOf("&vel=");
txtLed = readString.substring(txtLedI,txtLedF);
txtLed.replace("%20"," ");
Serial.print("NÚMERO LED: ");
Serial.println(txtLed);
if(txtLed.length() != 0){
tape = txtLed;
Serial.println("paso aqui");
}
//##SEPARANDO EL VALOR DE LA VARIABLE VELLED##//
int velLedI = readString.indexOf("&vel=") + 5;
int velLedF = readString.indexOf("FIN");
velLed = readString.substring(velLedI,velLedF);
velLedInt = velLed.toInt();
Serial.print("VELOCIDAD: ");
Serial.println(velLedInt);
int letter = 0;
int x = 31;
int y = 0;
int i = 0;
int width = 6;
if(velLedInt != 0){
wait = velLedInt;
}
}
String buf = "";
buf += "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n";
buf += "<html>";
buf += "<head>";
buf += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
buf += "<meta name='viewport' content='width=device-width,minimum-scale=1.0,maximum-scale=1.0'>";
buf += "<script type=\"text/javascript\">function mudarAction(){ var text = document.form1.text.value; var vel = document.form1.vel.value; document.form1.action = \"?a=ligar&txt=\"+text+\"&vel=\"+vel+\"FIM\"; document.form1.submit();}</script>";
buf += "<title>LETREIRO ONLINE</title>";
buf += "</head>";
buf += "<body>";
buf += "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">";
buf += "<table width=\"300\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
buf += "<tr>";
buf += "<td align=\"center\"><font face=\"verdana\" size=\"2\"><strong>LETRERO DIGITAL</strong></font></td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td> </td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td align=\"center\"><font face=\"verdana\" size=\"2\"><strong>TEXTO</strong></font></td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td align=\"center\">";
buf += "<input name=\"text\" type=\"text\" id=\"text\" size=\"49\" /></td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td align=\"center\"><font face=\"verdana\" size=\"2\"><strong>VELOCIDAD</strong></font></td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td><table border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">";
buf += "<tr>";
buf += "<td width=\"70\"><font face=\"verdana\" size=\"2\">ALTA</font></td>";
buf += "<td width=\"15\"><input type=\"radio\" name=\"vel\" id=\"vel1\" value=\"10\" />";
buf += "</td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td><font face=\"verdana\" size=\"2\">MEDIA</font></td>";
buf += "<td><input type=\"radio\" name=\"vel\" id=\"vel2\" value=\"30\" checked=\"checked\" /></td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td><font face=\"verdana\" size=\"2\">LENTA</font></td>";
buf += "<td><input type=\"radio\" name=\"vel\" id=\"vel3\" value=\"50\" /></td>";
buf += "</tr>";
buf += "</table></td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td> </td>";
buf += "</tr>";
buf += "<tr>";
buf += "<td align=\"center\"><input type=\"button\" name=\"button\" id=\"button\" value=\"ENVIAR\" onclick=\"mudarAction();\" /></td>";
buf += "</tr>";
buf += "</table>";
buf += "</form>";
buf += "</body>";
buf += "</html>";
client.print(buf);
client.flush();
client.stop();
readString="";
}
}
}
//break;
}
//####################################################################################//
int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically
while ( x + width - spacer >= 0 && letter >= 0 ) {
if ( letter < tape.length() ) {
matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
}
letter--;
x -= width;
}
matrix.write();
delay(wait);
}
}
Un saludo.