diff --git a/esp8266/command.cpp b/esp8266/command.cpp index 03280843..4addc0c4 100644 --- a/esp8266/command.cpp +++ b/esp8266/command.cpp @@ -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 diff --git a/esp8266/storestrings.cpp b/esp8266/storestrings.cpp new file mode 100644 index 00000000..0ab20969 --- /dev/null +++ b/esp8266/storestrings.cpp @@ -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 0 ) + { //is current cursor available or need a shift + if (storage_cursor > storage_size-1) + { + for (uint i=0;i 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; +} diff --git a/esp8266/storestrings.h b/esp8266/storestrings.h new file mode 100644 index 00000000..6bfeb496 --- /dev/null +++ b/esp8266/storestrings.h @@ -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 + +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 diff --git a/esp8266/webinterface.cpp b/esp8266/webinterface.cpp index 34afdc56..838220de 100644 --- a/esp8266/webinterface.cpp +++ b/esp8266/webinterface.cpp @@ -257,6 +257,9 @@ const char PRINTER_1b[]PROGMEM ="\n"; const char PRINTER_1d[]PROGMEM ="  \n"; const char PRINTER_1e[]PROGMEM ="
\n"; +const char PRINTER_1f[]PROGMEM ="

\n"; +const char PRINTER_1g[]PROGMEM ="

\n"; +const char PRINTER_1h[]PROGMEM ="
\n"; const char PRINTER_2[]PROGMEM ="\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 ="\n"; +const char DIV_ERRORMSG[]PROGMEM ="
\n"; +const char DIV_INFOMSG[]PROGMEM ="
\n"; +const char DIV_STATUSMSG[]PROGMEM ="
\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); diff --git a/esp8266/webinterface.h b/esp8266/webinterface.h index 58f322d1..3afff371 100644 --- a/esp8266/webinterface.h +++ b/esp8266/webinterface.h @@ -24,8 +24,9 @@ #include #include #include -#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: }; diff --git a/page5.png b/page5.png index 55802a0a..9d3aa71e 100644 Binary files a/page5.png and b/page5.png differ