mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-07-04 10:35:10 +08:00
Add Support for Error/Info/Status message
allows to store and display : the 10 last error messages , the last info messages, and the 10 last status changes
This commit is contained in:
parent
690792bc8d
commit
b1796e9107
@ -54,6 +54,9 @@ void COMMAND::check_command(String buffer)
|
||||
int Zpos = buffer.indexOf("Z:");
|
||||
int Speedpos = buffer.indexOf("SpeedMultiply:");
|
||||
int Flowpos = buffer.indexOf("FlowMultiply:");
|
||||
int Errorpos= buffer.indexOf("Error:");
|
||||
int Infopos= buffer.indexOf("Info:");
|
||||
int Statuspos= buffer.indexOf("Status:");
|
||||
if (ESPpos>-1)
|
||||
{//is there the second part?
|
||||
int ESPpos2 = buffer.indexOf("]",ESPpos);
|
||||
@ -90,6 +93,12 @@ void COMMAND::check_command(String buffer)
|
||||
if (Speedpos>-1)web_interface->answer4M220=buffer.substring(Speedpos+14);
|
||||
//Flow
|
||||
if (Flowpos>-1)web_interface->answer4M221=buffer.substring(Flowpos+13);
|
||||
//Error
|
||||
if (Errorpos>-1 && !(buffer.indexOf("Format error")!=-1 || buffer.indexOf("wait")==Errorpos+6) )(web_interface->error_msg).add(buffer.substring(Errorpos+6).c_str());
|
||||
//Info
|
||||
if (Infopos>-1)(web_interface->info_msg).add(buffer.substring(Infopos+5).c_str());
|
||||
//Status
|
||||
if (Statuspos>-1)(web_interface->status_msg).add(buffer.substring(Statuspos+7).c_str());
|
||||
}
|
||||
|
||||
//read a buffer in an array
|
||||
|
69
esp8266/storestrings.cpp
Normal file
69
esp8266/storestrings.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
storestrings.cpp - rolling storage class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "storestrings.h"
|
||||
#define MAX_STORAGE 20
|
||||
|
||||
STORESTRINGS_CLASS::STORESTRINGS_CLASS (uint8_t size){
|
||||
|
||||
storage_size = (size<MAX_STORAGE)?size:MAX_STORAGE;
|
||||
storage = new String[storage_size];
|
||||
storage_cursor=0;
|
||||
}
|
||||
|
||||
STORESTRINGS_CLASS::~STORESTRINGS_CLASS (){
|
||||
delete storage;
|
||||
storage_size = 0;
|
||||
}
|
||||
|
||||
bool STORESTRINGS_CLASS::add (const char * string){
|
||||
//check if if there is something to add
|
||||
if (strlen(string)> 0 )
|
||||
{ //is current cursor available or need a shift
|
||||
if (storage_cursor > storage_size-1)
|
||||
{
|
||||
for (uint i=0;i<storage_size-1;i++)
|
||||
{
|
||||
storage[i]=storage[i+1];
|
||||
}
|
||||
storage_cursor--;
|
||||
}
|
||||
storage[storage_cursor]=String(string);
|
||||
storage_cursor++;
|
||||
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
String STORESTRINGS_CLASS::get_index_at(uint pos)
|
||||
{
|
||||
if (pos > storage_size-1) return storage[storage_size-1];
|
||||
else return storage[pos];
|
||||
}
|
||||
|
||||
uint STORESTRINGS_CLASS::get_size()
|
||||
{
|
||||
return storage_size;
|
||||
}
|
||||
|
||||
int STORESTRINGS_CLASS::get_used_max_index()
|
||||
{
|
||||
if (storage_cursor > storage_size-1) return storage_size-1;
|
||||
else return storage_cursor-1;
|
||||
}
|
40
esp8266/storestrings.h
Normal file
40
esp8266/storestrings.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
storestrings.h - rolling storage class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef STORESTRINGS_h
|
||||
#define STORESTRINGS_h
|
||||
#include <Arduino.h>
|
||||
|
||||
class STORESTRINGS_CLASS
|
||||
{
|
||||
public:
|
||||
STORESTRINGS_CLASS (uint8_t size = 10);
|
||||
~STORESTRINGS_CLASS ();
|
||||
bool add (const char * string);
|
||||
String get_index_at(uint pos);
|
||||
uint get_size();
|
||||
int get_used_max_index();
|
||||
private:
|
||||
String * storage;
|
||||
uint storage_size;
|
||||
uint storage_cursor;
|
||||
};
|
||||
|
||||
#endif
|
@ -257,6 +257,9 @@ const char PRINTER_1b[]PROGMEM ="<TD ID=\"status\" NAME=\"status\" ></TD><TR></T
|
||||
const char PRINTER_1c[]PROGMEM ="<BR><TABLE BORDER=0><TR><TD ID=\"position\" NAME=\"position\"></TD>\n";
|
||||
const char PRINTER_1d[]PROGMEM ="<TD><LABEL>Speed:</LABEL><LABEL ID=\"speed\" NAME=\"speed\" class=\"text-info\"></LABEL><LABEL class=\"text-info\">%</LABEL> \n";
|
||||
const char PRINTER_1e[]PROGMEM ="<LABEL>Flow:</LABEL><LABEL ID=\"flow\" NAME=\"flow\" class=\"text-info\"></LABEL><LABEL class=\"text-info\">%</LABEL></TD></TR></TABLE><BR>\n";
|
||||
const char PRINTER_1f[]PROGMEM ="<TABLE BORDER=0><TR style=\"vertical-align:top\" ><TD><LABEL>Info:</LABEL></TD><TD ID=\"infomsg\" NAME=\"infomsg\" class=\"text-info\"></TD></TR></TABLE><HR>\n";
|
||||
const char PRINTER_1g[]PROGMEM ="<TABLE BORDER=0><TR style=\"vertical-align:top\"><TD><LABEL>Error:</LABEL></TD><TD ID=\"errormsg\" NAME=\"errormsg\" class=\"text-info\"></TD></TR></TABLE><HR>\n";
|
||||
const char PRINTER_1h[]PROGMEM ="<TABLE BORDER=0><TR style=\"vertical-align:top\"><TD><LABEL>Status:</LABEL></TD><TD ID=\"statusmsg\" NAME=\"statusmsg\" class=\"text-info\"></TD></TR></TABLE>\n";
|
||||
|
||||
const char PRINTER_2[]PROGMEM ="<iframe ID=\"dataframe\" NAME=\"dataframe\"src=\"http://";
|
||||
const char PRINTER_3[]PROGMEM ="/STATUS\" frameborder=0 width=\"320\" height=\"300\" style=\"visibility:hidden;\"></iframe>\n";
|
||||
@ -267,12 +270,18 @@ const char PRINTER_6b[]PROGMEM ="document.getElementById(\"position\").innerHTML
|
||||
const char PRINTER_6c[]PROGMEM ="document.getElementById(\"speed\").innerHTML=doc.getElementById(\"speed\").innerHTML;\n";
|
||||
const char PRINTER_6d[]PROGMEM ="document.getElementById(\"flow\").innerHTML=doc.getElementById(\"flow\").innerHTML;\n";
|
||||
const char PRINTER_6e[]PROGMEM ="document.getElementById(\"status\").innerHTML=doc.getElementById(\"status\").innerHTML;\n";
|
||||
const char PRINTER_6f[]PROGMEM ="document.getElementById(\"infomsg\").innerHTML=doc.getElementById(\"infomsg\").innerHTML;\n";
|
||||
const char PRINTER_6g[]PROGMEM ="document.getElementById(\"errormsg\").innerHTML=doc.getElementById(\"errormsg\").innerHTML;\n";
|
||||
const char PRINTER_6h[]PROGMEM ="document.getElementById(\"statusmsg\").innerHTML=doc.getElementById(\"statusmsg\").innerHTML;\n";
|
||||
const char PRINTER_7[]PROGMEM ="}\n";
|
||||
const char PRINTER_8[]PROGMEM ="setInterval(function(){";
|
||||
const char PRINTER_9[]PROGMEM ="var ifrm=document.getElementById(\"dataframe\");var doc=ifrm.contentDocument?ifrm.contentDocument:ifrm.contentWindow.document;";
|
||||
const char PRINTER_10[]PROGMEM ="doc.location.reload(true);";
|
||||
const char PRINTER_11[]PROGMEM ="},2000);\n";
|
||||
const char PRINTER_12[]PROGMEM ="</SCRIPT>\n";
|
||||
const char DIV_ERRORMSG[]PROGMEM ="<DIV ID=\"errormsg\" NAME=\"errormsg\">\n";
|
||||
const char DIV_INFOMSG[]PROGMEM ="<DIV ID=\"infomsg\" NAME=\"infomsg\">\n";
|
||||
const char DIV_STATUSMSG[]PROGMEM ="<DIV ID=\"statusmsg\" NAME=\"statusmsg\">\n";
|
||||
|
||||
#define TEMP_SVG(temperature,target,description) buffer2send+=(PROGMEM2CHAR(TEMP_SVG_1));buffer2send+=(PROGMEM2CHAR(TEMP_SVG_2));buffer2send+=(PROGMEM2CHAR(TEMP_SVG_3));buffer2send+=(PROGMEM2CHAR(TEMP_SVG_4));buffer2send+=(PROGMEM2CHAR(TEMP_SVG_5));buffer2send+=String(target+10); buffer2send+=(PROGMEM2CHAR(TEMP_SVG_6));buffer2send+=String(target+10); buffer2send+=(PROGMEM2CHAR(TEMP_SVG_7));buffer2send+=(PROGMEM2CHAR(TEMP_SVG_8));buffer2send+=String(temperature+5);buffer2send+=(PROGMEM2CHAR(TEMP_SVG_9));buffer2send+=String(temperature+15);buffer2send+=(PROGMEM2CHAR(TEMP_SVG_10));buffer2send+=String(temperature+10);buffer2send+=(PROGMEM2CHAR(TEMP_SVG_11));buffer2send+=String(temperature+5);buffer2send+=(PROGMEM2CHAR(TEMP_SVG_12));buffer2send+=String(temperature+15);buffer2send+=(PROGMEM2CHAR(TEMP_SVG_13));buffer2send+=String(temperature+10);buffer2send+=(PROGMEM2CHAR(TEMP_SVG_14));buffer2send+=description;buffer2send+=(PROGMEM2CHAR(TEMP_SVG_15));buffer2send+=(PROGMEM2CHAR(TEMP_SVG_16));
|
||||
|
||||
@ -1440,6 +1449,9 @@ void handle_web_interface_printer()
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_1c));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_1d));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_1e));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_1f));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_1g));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_1h));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_2));
|
||||
buffer2send+=stmp.c_str();
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_3));
|
||||
@ -1450,6 +1462,9 @@ void handle_web_interface_printer()
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_6c));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_6d));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_6e));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_6f));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_6g));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_6h));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_7));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_8));
|
||||
buffer2send+=(PROGMEM2CHAR(PRINTER_9));
|
||||
@ -1559,6 +1574,41 @@ void handle_web_interface_status()
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_STATUS));
|
||||
STATUS_SVG(status_color)
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_E));
|
||||
int p=1;
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_INFOMSG));
|
||||
if (web_interface->info_msg.get_used_max_index()>-1)
|
||||
for (int i=web_interface->info_msg.get_used_max_index();i>=0;i--)
|
||||
{
|
||||
buffer2send+=String(p);
|
||||
buffer2send+="-";
|
||||
p++;
|
||||
buffer2send+=web_interface->info_msg.get_index_at(i);
|
||||
buffer2send+=(PROGMEM2CHAR(BR));
|
||||
}
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_E));
|
||||
p=1;
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_ERRORMSG));
|
||||
if (web_interface->error_msg.get_used_max_index()>-1)
|
||||
for (int i=web_interface->error_msg.get_used_max_index();i>=0;i--)
|
||||
{
|
||||
buffer2send+=String(p);
|
||||
buffer2send+="-";
|
||||
p++;
|
||||
buffer2send+=web_interface->error_msg.get_index_at(i);
|
||||
buffer2send+=(PROGMEM2CHAR(BR));
|
||||
}
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_E));
|
||||
p=1;
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_STATUSMSG));
|
||||
if (web_interface->status_msg.get_used_max_index()>-1)
|
||||
for (int i=web_interface->status_msg.get_used_max_index();i>=0;i--)
|
||||
{ buffer2send+=String(p);
|
||||
buffer2send+="-";
|
||||
p++;
|
||||
buffer2send+=web_interface->status_msg.get_index_at(i);
|
||||
buffer2send+=(PROGMEM2CHAR(BR));
|
||||
}
|
||||
buffer2send+=(PROGMEM2CHAR(DIV_E));
|
||||
buffer2send+=(PROGMEM2CHAR(DATA_E));
|
||||
web_interface->WebServer.send(200, "text/html", buffer2send);
|
||||
|
||||
|
@ -24,8 +24,9 @@
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#define MAX_EXTRUDERS 4
|
||||
#include "storestrings.h"
|
||||
|
||||
#define MAX_EXTRUDERS 4
|
||||
|
||||
class WEBINTERFACE_CLASS
|
||||
{
|
||||
@ -41,6 +42,9 @@ class WEBINTERFACE_CLASS
|
||||
String answer4M220;
|
||||
String answer4M221;
|
||||
uint32_t last_temp;
|
||||
STORESTRINGS_CLASS error_msg;
|
||||
STORESTRINGS_CLASS info_msg;
|
||||
STORESTRINGS_CLASS status_msg;
|
||||
private:
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user