diff --git a/Arduino/CanGrow/include/CanGrow.h b/Arduino/CanGrow/include/CanGrow.h index fca6e19..3947b34 100644 --- a/Arduino/CanGrow/include/CanGrow.h +++ b/Arduino/CanGrow/include/CanGrow.h @@ -68,6 +68,7 @@ const byte BOOTFAILS_HIGH = 2; const byte FLASHMODE_LOW = 3; const byte INPUT_ONLY = 4; const byte NO_PWM = 5; +const byte HIGH_BOOT = 6; struct GPIO_Index { const byte gpio; diff --git a/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h b/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h index 6a22d7c..fd374f5 100644 --- a/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h +++ b/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h @@ -204,6 +204,10 @@ input[type=text], input[type=date], input[type=number], input[type=password], se border-radius: 3px; } +.hidden { + display: none; +} + @media only screen and (min-width: 1820px) { /*.center, .nav { width: 60; min-width: 420px; diff --git a/Arduino/CanGrow/include/Webserver/Page_system.h b/Arduino/CanGrow/include/Webserver/Page_system.h index 4012f36..ef96e7d 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system.h +++ b/Arduino/CanGrow/include/Webserver/Page_system.h @@ -359,6 +359,31 @@ String Proc_WebPage_system_output_add(const String& var) { return AddHeaderFooter(var, 2); } else if(Test_WebPage_system_SUBNAV(var)) { return Proc_WebPage_system_SUBNAV(var, 1); + } else if(var == "GPIO_INDEX") { + String gpioIndex_html; + for(byte i = 0; i < GPIOindex_length; i++) { + gpioIndex_html += ""; + + + + } + return String(Common_HTML_SAVE_MSG); } else{ return String(); } @@ -372,14 +397,41 @@ String Proc_WebPage_system_output_add_POST(const String& var) { } } +// https://github.com/mathieucarbou/ESPAsyncWebServer?tab=readme-ov-file#chunked-response-containing-templates +auto Chunk_system_output_add_HTML(uint8_t *buffer, size_t maxLen, size_t alreadySent) -> size_t { + //Write up to "maxLen" bytes into "buffer" and return the amount written. + //index equals the amount of bytes that have been already sent + //You will be asked for more data until 0 is returned + //Keep in mind that you can not delay or yield waiting for more data! + + // https://forum.arduino.cc/t/espasyncwebserver-replay-page-size/1049106/19 + //const int len_html = sizeof(Page_system_output_add_HTML)/sizeof(Page_system_output_add_HTML[0]); + //size_t len = min(maxLen, String(Page_system_output_add_HTML).length() - index); + //Serial.printf("Sending %u bytes\n", len); + //memcpy(buffer, String(Page_system_output_add_HTML).c_str() + index, len); + //return len; + const size_t size = sizeof Page_system_output_add_HTML; + if (size - alreadySent >= maxLen) { + memcpy(buffer, Page_system_output_add_HTML + alreadySent, maxLen); + return maxLen; + } else { // last chunk and then 0 + memcpy(buffer, Page_system_output_add_HTML + alreadySent, size - alreadySent); + return size - alreadySent; + } +} + + + + void WebPage_system_output_add(AsyncWebServerRequest *request) { if(request->method() == HTTP_POST) { - request->send_P(200, "text/html", Page_system_output_add_HTML, Proc_WebPage_system_output_add_POST); + AsyncWebServerResponse *response = request->beginChunkedResponse("text/plain", Chunk_system_output_add_HTML); + request->send(response); Serial.println(":: [Webserver:system:output:add] [POST] hello"); } else { - request->send_P(200, "text/html", Page_system_output_add_HTML, Proc_WebPage_system_output_add); + request->beginChunkedResponse("text/html", Chunk_system_output_add_HTML); } } diff --git a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h index 018ca39..75d18bd 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h +++ b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h @@ -156,4 +156,81 @@ const char* Page_system_output_HTML PROGMEM = R"(%HEADER% const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER% %SUBNAV%

➕ Add output

+ +

Add a new output to CanGrow.

+
+ +Type:
+
+ +Device:
+
+ +Name:
+
+ +Enable:
+
+ + + + + + + + +
+ + +
+ %FOOTER%)";