diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index aaa5177..cafc769 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -131,9 +131,9 @@ void setup() { LoadConfig(); Wifi_Init(); Webserver_Init(); - Serial.printf("Usable Pins: %d\n", PinIndex_length); - for(byte i = 0; i < PinIndex_length; i++) { - Serial.printf("Pin Index: %d, GPIO: %d, Notes: %d\n", i, PinIndex[i].gpio, PinIndex[i].note); + Serial.printf(":: [SETUP] Usable Pins: %d\n", GPIOindex_length); + for(byte i = 0; i < GPIOindex_length; i++) { + Serial.printf(":: [SETUP] Pin Index: %d, GPIO: %d, Notes: %d\n", i, GPIOindex[i].gpio, GPIOindex[i].note); } } diff --git a/Arduino/CanGrow/include/CanGrow.h b/Arduino/CanGrow/include/CanGrow.h index bf35b17..a9f1cc2 100644 --- a/Arduino/CanGrow/include/CanGrow.h +++ b/Arduino/CanGrow/include/CanGrow.h @@ -52,10 +52,10 @@ #define CANGROW_SSID "CanGrow-unconfigured" -/* actual structure initialization for Pin_Index is done within the header files +/* actual structure initialization for GPIO_Index is done within the header files * for ESP32 and ESP8266 * - * Pin_Index.note explenation: + * GPIO_Index.note explenation: * 1 - BOOTFAILS_LOW: BootFails when LOW * 2 - BOOTFAILS_HIGH: BootFails when HIGH * 3 - FLASHMODE_LOW: FlashMode needs LOW to enter @@ -69,13 +69,16 @@ const byte FLASHMODE_LOW = 3; const byte INPUT_ONLY = 4; const byte NO_PWM = 5; -struct Pin_Index { +struct GPIO_Index { const byte gpio; const byte note; }; const byte Max_Outputs = 16; +const char[] Output_Types= { "GPIO" , "I2C", "URL" } +byte Output_Types_len = 3; + /* * * Config @@ -103,7 +106,7 @@ struct Config_WiFi { struct Config_System_Output { /* - * Config System Outputs + * Config System Output * * - output_type: output type like GPIO, I2C, URL * 1 - GPIO diff --git a/Arduino/CanGrow/include/CanGrow_ESP32.h b/Arduino/CanGrow/include/CanGrow_ESP32.h index 4ba7f0c..c1bd1c2 100644 --- a/Arduino/CanGrow/include/CanGrow_ESP32.h +++ b/Arduino/CanGrow/include/CanGrow_ESP32.h @@ -61,9 +61,9 @@ // -const byte PinIndex_length = 21; +const byte GPIOindex_length = 21; // initialize pinIndex with all usable GPIOs -Pin_Index PinIndex[] = { { 0, FLASHMODE_LOW }, +GPIO_Index GPIOindex[] = { { 0, FLASHMODE_LOW }, { 4 }, { 5 }, { 12, BOOTFAILS_HIGH }, diff --git a/Arduino/CanGrow/include/CanGrow_ESP8266.h b/Arduino/CanGrow/include/CanGrow_ESP8266.h index 4129ffe..98eefa2 100644 --- a/Arduino/CanGrow/include/CanGrow_ESP8266.h +++ b/Arduino/CanGrow/include/CanGrow_ESP8266.h @@ -45,9 +45,9 @@ * - GPIO 16 / D0 */ -const byte PinIndex_length = 6; +const byte GPIOindex_length = 6; // initialize pinIndex with all usable GPIOs -Pin_Index PinIndex[] = { { 0, BOOTFAILS_LOW }, +GPIO_Index GPIOindex[] = { { 0, BOOTFAILS_LOW }, { 12 }, { 13 }, { 14 }, diff --git a/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h b/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h index f61e4a6..47395f6 100644 --- a/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h +++ b/Arduino/CanGrow/include/Webserver/File_cangrow_CSS.h @@ -37,7 +37,6 @@ const char* File_cangrow_CSS PROGMEM = R"(body { .footer { color: #343B35; - /*text-align: center;*/ } .center { @@ -46,15 +45,10 @@ const char* File_cangrow_CSS PROGMEM = R"(body { } .centered { - display: block; margin-left: auto; margin-right: auto; } -/*h1, h2, h3, h4, h5 { - text-align: center; -}*/ - h1 { margin: 15px; } diff --git a/Arduino/CanGrow/include/Webserver/Page_system.h b/Arduino/CanGrow/include/Webserver/Page_system.h index 0fd3cf1..4012f36 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system.h +++ b/Arduino/CanGrow/include/Webserver/Page_system.h @@ -300,6 +300,28 @@ String Proc_WebPage_system_output(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_TR_TD") { + // build table body + // i dont know a better way at the moment. if you do, please tell me! + String output_tr_td; + for(byte i=0; i < Max_Outputs; i++) { + Serial.printf("DB [Webserver:system:output(Proc)] OutputID %d Type %d\n", i, config.system.output.type[i]); + output_tr_td += ""; + output_tr_td += i; + output_tr_td += ""; + output_tr_td += config.system.output.name[i]; + output_tr_td += ""; + output_tr_td += config.system.output.type[i]; + output_tr_td += ""; + output_tr_td += config.system.output.device[i]; + output_tr_td += "✏️ "; + } + + return output_tr_td; } else{ return String(); } diff --git a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h index f806c5b..018ca39 100644 --- a/Arduino/CanGrow/include/Webserver/Page_system_HTML.h +++ b/Arduino/CanGrow/include/Webserver/Page_system_HTML.h @@ -138,6 +138,16 @@ const char* Page_system_wipe_HTML_WIPE_MSG_POST PROGMEM = R"(Restarting...)"; const char* Page_system_output_HTML PROGMEM = R"(%HEADER% %SUBNAV% ➕ Add output + + + + + + + + + %OUTPUT_TR_TD% +
IDNameTypeDeviceAction
%FOOTER%)"; /* diff --git a/playground/html/root/index.html b/playground/html/root/index.html index 11b3cb5..0873cf0 100644 --- a/playground/html/root/index.html +++ b/playground/html/root/index.html @@ -25,13 +25,13 @@ ➕ Add output - + - + @@ -68,5 +68,86 @@
ID Name Type Device Action
0 LED main✏️
+ + +

Add a new output to CanGrow.

+
+ +Type:
+
+ +Device:
+
+ +Name:
+
+ +Enable:
+
+ + +
+ GPIO:
+
+ + GPIO PWM:
+
+
+ + +
+I2C:
+
+
+ +
+ Host:
+
+ + URI on:
+
+ + URI off:
+
+
+ + + +
+ + + + + +