From 301a9d1beacc420d9c79c4abed8e12ab2be47d0c Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Mon, 1 May 2023 19:00:00 +0200 Subject: [PATCH] Reverted to old html code generation. --- firmware/config_html.h | 64 ---- firmware/config_html.html | 62 ++++ firmware/firmware.ino | 509 +++++++++++++++++++++++++------ firmware/index_html.h | 275 ----------------- firmware/index_html.html | 274 +++++++++++++++++ firmware/light_control_html.h | 32 -- firmware/light_control_html.html | 29 ++ 7 files changed, 789 insertions(+), 456 deletions(-) create mode 100644 firmware/config_html.html create mode 100644 firmware/index_html.html create mode 100644 firmware/light_control_html.html diff --git a/firmware/config_html.h b/firmware/config_html.h index 4b42bb1..e69de29 100644 --- a/firmware/config_html.h +++ b/firmware/config_html.h @@ -1,64 +0,0 @@ -const String config_html = ""; -const String config_html2 = R"=====( -
-

Config

-
- - -
-
- - -
-
-

Wifi

-
- - -
-
- - -
-
-

Network

-
- - ON - OFF -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
-
-)====="; diff --git a/firmware/config_html.html b/firmware/config_html.html new file mode 100644 index 0000000..b921a0a --- /dev/null +++ b/firmware/config_html.html @@ -0,0 +1,62 @@ +
+

Config

+
+ + +
+
+ + +
+
+

Wifi

+
+ + +
+
+ + +
+
+

Network

+
+ + ON + OFF +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ diff --git a/firmware/firmware.ino b/firmware/firmware.ino index a8ade2a..ac1600b 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -610,118 +610,457 @@ void init_webserver() } // Generate HTML page - String http_content = index_html; + String http_content = ""; + http_content += ""; + http_content += ""; + http_content += ""; + http_content += ""; + http_content += ""; + //http_content += ""; // Reload the page every 15 seconds automatically + http_content += "Light Setup"; + http_content += ""; + http_content += ""; + http_content += ""; + http_content += ""; + http_content += ""; + http_content += ""; + http_content += "
"; + http_content += "

" + (String)light_name + "

"; - http_content.replace("{{LIGHT_NAME}}", (String)light_name); + http_content += "
"; + http_content += "
"; + http_content += "alert   reset   reset timing control data   update"; + http_content += ""; + http_content += "
"; + + // timing control button + http_content += "
"; + http_content += "
"; + http_content += ""; int tc_val = EEPROM.read(EEPROM_TIMING_CONTROL_ENABLED_ADDRESS); - if (tc_val == TIMING_CONTROL_ENABLED) - { - http_content.replace("{{TC_LINK_PRIMARY_ON}}", "pure-button-primary"); - } else { - http_content.replace("{{TC_LINK_PRIMARY_ON}}", ""); - } - if (tc_val == TIMING_CONTROL_DISABLED) - { - http_content.replace("{{TC_LINK_PRIMARY_OFF}}", "pure-button-primary"); - } else { - http_content.replace("{{TC_LINK_PRIMARY_OFF}}", ""); - } + http_content += "ON"; + http_content += "OFF"; + http_content += "
"; + http_content += ""; + http_content += "
"; - http_content.replace("{{TRANSITION_TIME}}", (String)default_transitiontime); + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; + http_content += "
"; - String light_content = ""; + http_content += ""; + + http_content += "
"; // Light control for (uint8 light_num = 0; light_num < LIGHTS_COUNT; light_num++) { - // Generate lights part of the HTML page - String tmp_light_content = light_html; + // on/off buttons + http_content += "

Light " + (String)(light_num + 1) + "

"; + http_content += "
"; + http_content += ""; + http_content += "ON"; + http_content += "OFF"; + http_content += "
"; - // on/off buttons and slider - tmp_light_content.replace("{{LIGHT_NUMBER}}", (String)(light_num + 1)); - tmp_light_content.replace("{{LIGHT_NUMBER_DEC}}", (String)light_num); + // slider for brightness + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += " " + (String)(int)(bri[light_num] * 100.0 / 255.0) + "%"; + http_content += "
"; + http_content += ""; + http_content += " %"; + http_content += ""; + + http_content += "
"; - // add the lights code to the html output string - light_content += tmp_light_content; } + http_content += ""; - // add the created lights control code to the html output - http_content.replace("{{LIGHTS_CONTROL}}", light_content); + http_content += "
"; + // startup state and scene for all of the lights + http_content += "
"; + http_content += "
"; + http_content += "

"; + http_content += "

Config

"; + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; // scene + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; // Wifi settings - config_content.replace("{{WIFI_SSIF}}", WiFi.SSID()); + http_content += "
"; + http_content += "

Wifi

"; + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; // Network settings uint8_t dip = EEPROM.read(EEPROM_DYNAMIC_IP_ADDRESS); - if (dip) - { - config_content.replace("{{DIP_LINK_ON_PRIMARY}}", "pure-button-primary"); - config_content.replace("{{DIP_LINK_OFF_PRIMARY}}", ""); - } else { - config_content.replace("{{DIP_LINK_OFF_PRIMARY}}", "pure-button-primary"); - config_content.replace("{{DIP_LINK_ON_PRIMARY}}", ""); - } + http_content += "
"; + http_content += "

Network

"; + http_content += "
"; + http_content += ""; + http_content += "ON"; + http_content += "OFF"; + http_content += "
"; // ip config - if (dip == 0) - { - config_content.replace("{{WIFI_IP}}", WiFi.localIP().toString()); - config_content.replace("{{WIFI_GW}}", WiFi.gatewayIP().toString()); - config_content.replace("{{WIFI_NM}}", WiFi.subnetMask().toString()); - config_content.replace("{{WIFI_DNS}}", WiFi.dnsIP().toString()); + if (dip == 0) { + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; + http_content += "
"; + http_content += ""; + http_content += ""; + http_content += "
"; } - http_content.replace("{{CONFIG_PAGE}}", config_content); + // The save button + http_content += "
"; + http_content += ""; + http_content += "
"; - // set the pwm values - http_content.replace("{{PWM_MIN}}", (String)PWM_MIN); - http_content.replace("{{PWM_MAX}}", (String)PWM_MAX); + http_content += ""; + + http_content += ""; + http_content += "
"; + http_content += "
"; + http_content += ""; + http_content += ""; server.send(200, "text/html", http_content); }); diff --git a/firmware/index_html.h b/firmware/index_html.h index ee9f9c0..e69de29 100644 --- a/firmware/index_html.h +++ b/firmware/index_html.h @@ -1,275 +0,0 @@ -const String index_html = ""; -const String index_html2 = R"=====( - - - - - - Light setup - - - - - - -
-

{{LIGHT_NAME}}

-
-
- - alert -   - reset -   - reset timing control data -   - update - - -
-
-
- - ON - OFF -
- -
-
- - -
-
- -
- - - - - -
-{{LIGHTS_CONTROL}} - - -
-
- {{CONFIG_PAGE}} - -
-
- -)====="; diff --git a/firmware/index_html.html b/firmware/index_html.html new file mode 100644 index 0000000..2359b69 --- /dev/null +++ b/firmware/index_html.html @@ -0,0 +1,274 @@ + + + + + + + Light setup + + + + + + +
+

{{LIGHT_NAME}}

+
+
+ + alert +   + reset +   + reset timing control data +   + update + + +
+
+
+ + ON + OFF +
+ +
+
+ + +
+
+ +
+ + + + + +
+{{LIGHTS_CONTROL}} + + +
+
+ {{CONFIG_PAGE}} + +
+
+ + \ No newline at end of file diff --git a/firmware/light_control_html.h b/firmware/light_control_html.h index 6418675..e69de29 100644 --- a/firmware/light_control_html.h +++ b/firmware/light_control_html.h @@ -1,32 +0,0 @@ -const String light_html = ""; -const String light_html2 = R"=====( -

Light {{LIGHT_NUMBER}}

-
- - ON - OFF -
-
- - -   - 9 - % -
- - -   - - % - -
-)====="; diff --git a/firmware/light_control_html.html b/firmware/light_control_html.html new file mode 100644 index 0000000..be21046 --- /dev/null +++ b/firmware/light_control_html.html @@ -0,0 +1,29 @@ +

Light {{LIGHT_NUMBER}}

+
+ + ON + OFF +
+
+ + +   + 9 + % +
+ + +   + + % + +