diff --git a/Arduino/CanGrow/include/Webserver/Page_system.h b/Arduino/CanGrow/include/Webserver/Page_system.h index 92172a5..731f604 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system.h +++ b/Arduino/CanGrow/include/Webserver/Page_system.h @@ -359,6 +359,22 @@ 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 == "OUTPUT_ID") { + // we check which id is free. A free ID as type == 0 + byte freeOutputId; + + for(byte i=0; i < Max_Outputs; i++) { + if(config.system.output.type[i] > 0) { + // here i define that 255 stands for "not available" + freeOutputId = 255; + } else { + freeOutputId = i; + break; + } + } + Serial.printf("DB [Webserver:system:output:add(Proc)] next free output id: %d\n", freeOutputId); + return String(freeOutputId); + } else if(var == "GPIO_INDEX") { String gpioIndex_html; for(byte i = 0; i < GPIOindex_length; i++) { @@ -384,7 +400,7 @@ String Proc_WebPage_system_output_add(const String& var) { } return gpioIndex_html; - } else{ + } else { return String(); } } @@ -410,7 +426,9 @@ auto Chunk_system_output_add_HTML(uint8_t *buffer, size_t maxlen, size_t index) // https://forum.arduino.cc/t/strlen-and-progmem/629376/3 size_t len_html = strlen_P(reinterpret_cast(Page_system_output_add_HTML)); size_t len = min(maxlen, len_html - index); + #ifdef DEBUG Serial.printf(":: [Webserver:system:output:add(Chunked)] Sending len %u bytes , maxlen %u, index %u, sizeof %u\n", len, maxlen, index, len_html); + #endif memcpy(buffer, Page_system_output_add_HTML + index, len); return len; } diff --git a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h index 75d18bd..33e76bf 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h +++ b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h @@ -159,7 +159,7 @@ const char* Page_system_output_add_HTML PROGMEM = R"(%HEADER%

Add a new output to CanGrow.

- + Type:

Name:
-
+
Enable:
+
GPIO PWM:
-