Compare commits

..

2 commits

Author SHA1 Message Date
Kai Lauterbach
e0310f8c40 tc link switches in website are now automaticalle optical changes in relation to tc_enabled state. 2023-04-30 10:48:32 +02:00
Kai Lauterbach
eb33c94bf2 html page improved. 2023-04-29 20:45:17 +02:00
2 changed files with 63 additions and 52 deletions

View file

@ -628,13 +628,70 @@ void init_webserver()
http_content += "<fieldset>"; http_content += "<fieldset>";
http_content += "<h3>" + (String)light_name + "</h3>"; http_content += "<h3>" + (String)light_name + "</h3>";
http_content += "<div class=\"pure-form pure-form-aligned\">";
http_content += "<div class=\"pure-controls\">"; http_content += "<div class=\"pure-controls\">";
http_content += "<span class=\"pure-form-message\"><a href=\"/?alert=1\">alert</a> &nbsp; <a href=\"/?reset=1\">reset</a> &nbsp; <a href=\"/?resettc\">reset timing control data</a> &nbsp; <a href=\"/update\">update</a></span>"; http_content += "<span class=\"pure-form-message\"><a href=\"/?alert=1\">alert</a> &nbsp; <a href=\"/?reset=1\">reset</a> &nbsp; <a href=\"/?resettc\">reset timing control data</a> &nbsp; <a href=\"/update\">update</a></span>";
http_content += "<label for=\"cb\" class=\"pure-checkbox\">"; http_content += "<label for=\"cb\" class=\"pure-checkbox\">";
http_content += "</label>"; http_content += "</label>";
http_content += "</div>"; http_content += "</div>";
http_content += "<form class=\"pure-form pure-form-aligned\" action=\"/\" method=\"post\">"; // timing control button
http_content += "<br>";
http_content += "<div class=\"pure-control-group\">";
http_content += "<label for=\"tc_on\"><strong>Timing control</strong></label>";
int tc_val = EEPROM.read(EEPROM_TIMING_CONTROL_ENABLED_ADDRESS);
http_content += "<a id=\"tc_on\" class=\"pure-button";
if (tc_val == TIMING_CONTROL_ENABLED) http_content += " pure-button-primary";
http_content += "\" href=\"#\">ON</a>";
http_content += "<a id=\"tc_off\" class=\"pure-button";
if (tc_val == TIMING_CONTROL_DISABLED) http_content += " pure-button-primary";
http_content += "\" href=\"#\">OFF</a>";
http_content += "</div>";
http_content += "<script>"
// Suche nach allen tc Links auf der Seite mit IDs tc_on
"var links = document.querySelectorAll('[id^=\"tc_on\"]');"
// Füge einen Klick-Listener zu jedem Link hinzu
"links.forEach(function(link) {"
"link.addEventListener('click', function(event) {"
// Verhindere, dass der Link die Seite neu lädt
"event.preventDefault();"
// Erstelle eine neue Anfrage an die entsprechende URL
"var xhr = new XMLHttpRequest();"
"xhr.open('GET', 'http://192.168.0.26/?tc=true', true);"
// Sende die Anfrage im Hintergrund
"xhr.send();"
"console.log('tc=true call');"
"document.getElementById('tc_on').classList.add('pure-button-primary');"
"document.getElementById('tc_off').classList.remove('pure-button-primary');"
"});"
"});"
// Suche nach allen tc Links auf der Seite mit IDs tc_off
"var links = document.querySelectorAll('[id^=\"tc_off\"]');"
// Füge einen Klick-Listener zu jedem Link hinzu
"links.forEach(function(link) {"
"link.addEventListener('click', function(event) {"
// Verhindere, dass der Link die Seite neu lädt
"event.preventDefault();"
// Erstelle eine neue Anfrage an die entsprechende URL
"var xhr = new XMLHttpRequest();"
"xhr.open('GET', 'http://192.168.0.26/?tc=false', true);"
// Sende die Anfrage im Hintergrund
"xhr.send();"
"console.log('tc=false call');"
"document.getElementById('tc_off').classList.add('pure-button-primary');"
"document.getElementById('tc_on').classList.remove('pure-button-primary');"
"});"
"});"
"</script>";
http_content += "<br>";
http_content += "<div class=\"pure-control-group\">";
http_content += "<label for=\"transition\">Transition time (s)</label>";
http_content += "<input id=\"transition\" name=\"transition\" type=\"text\" placeholder=\"10\" value=\"" + (String)default_transitiontime + "\">";
http_content += "</div>";
http_content += "<br>";
http_content += "<script>" http_content += "<script>"
"let timeoutId;" // slider value change submit to server "let timeoutId;" // slider value change submit to server
"function sendSliderValue(x) {" "function sendSliderValue(x) {"
@ -722,39 +779,10 @@ void init_webserver()
"updateLightState();" "updateLightState();"
"});" "});"
"});" "});"
// Suche nach allen tc Links auf der Seite mit IDs tc_on
"var links = document.querySelectorAll('[id^=\"tc_on\"]');"
// Füge einen Klick-Listener zu jedem Link hinzu
"links.forEach(function(link) {"
"link.addEventListener('click', function(event) {"
// Verhindere, dass der Link die Seite neu lädt
"event.preventDefault();"
// Erstelle eine neue Anfrage an die entsprechende URL
"var xhr = new XMLHttpRequest();"
"xhr.open('GET', 'http://192.168.0.26/?tc=true', true);"
// Sende die Anfrage im Hintergrund
"xhr.send();"
"updateLightState();"
"});"
"});"
// Suche nach allen tc Links auf der Seite mit IDs tc_off
"var links = document.querySelectorAll('[id^=\"tc_off\"]');"
// Füge einen Klick-Listener zu jedem Link hinzu
"links.forEach(function(link) {"
"link.addEventListener('click', function(event) {"
// Verhindere, dass der Link die Seite neu lädt
"event.preventDefault();"
// Erstelle eine neue Anfrage an die entsprechende URL
"var xhr = new XMLHttpRequest();"
"xhr.open('GET', 'http://192.168.0.26/?tc=false', true);"
// Sende die Anfrage im Hintergrund
"xhr.send();"
"updateLightState();"
"});"
"});"
"</script>"; "</script>";
http_content += "<form class=\"pure-form pure-form-aligned\" action=\"/\" method=\"post\">";
// startup state and scene for all of the lights // startup state and scene for all of the lights
http_content += "</td><td>"; http_content += "</td><td>";
http_content += "<div id=\"plot_chart\"></div>"; http_content += "<div id=\"plot_chart\"></div>";
@ -793,24 +821,6 @@ void init_webserver()
http_content += "</select>"; http_content += "</select>";
http_content += "</div>"; http_content += "</div>";
// timing control button
http_content += "<div class=\"pure-control-group\">";
http_content += "<label for=\"tc\"><strong>Timing control</strong></label>";
int tc_val = EEPROM.read(EEPROM_TIMING_CONTROL_ENABLED_ADDRESS);
http_content += "<a id=\"tc_on\" class=\"pure-button";
if (tc_val == TIMING_CONTROL_ENABLED) http_content += " pure-button-primary";
http_content += "\" href=\"#\">ON</a>";
http_content += "<a id=\"tc_off\" class=\"pure-button";
if (tc_val == TIMING_CONTROL_DISABLED) http_content += " pure-button-primary";
http_content += "\" href=\"#\">OFF</a>";
http_content += "</div>";
http_content += "<br>";
http_content += "<div class=\"pure-control-group\">";
http_content += "<label for=\"transition\">Transition time (s)</label>";
http_content += "<input id=\"transition\" name=\"transition\" type=\"text\" placeholder=\"10\" value=\"" + (String)default_transitiontime + "\">";
http_content += "</div>";
// Wifi settings // Wifi settings
http_content += "<br>"; http_content += "<br>";
http_content += "<h3>Wifi</h3>"; http_content += "<h3>Wifi</h3>";
@ -1050,8 +1060,9 @@ void init_webserver()
#endif // DISABLE_WEB_CONTROL #endif // DISABLE_WEB_CONTROL
http_content += "</fieldset>";
http_content += "</form>"; http_content += "</form>";
http_content += "</div>";
http_content += "</fieldset>";
http_content += "</body>"; http_content += "</body>";
http_content += "</html>"; http_content += "</html>";

View file

@ -43,7 +43,7 @@ uint8_t example_timer_data_block[] = {
// hour min ch1 ch2 ch3 ch3 // hour min ch1 ch2 ch3 ch3
8, 0, 0, 0, 0, 0, // 0: off 8, 0, 0, 0, 0, 0, // 0: off
8, 30, 25, 0, 0, 0, // 1: 10% ch1 blues 8, 30, 25, 0, 0, 0, // 1: 10% ch1 blues
9, 0, 25, 0, 25, 0, // 2: 10% all blues 11, 0, 25, 0, 25, 0, // 2: 10% all blues
13, 0, 205, 205, 205, 205, // 3: 80% all 13, 0, 205, 205, 205, 205, // 3: 80% all
18, 0, 205, 205, 205, 205, // 4: 80% all for 5 hours 18, 0, 205, 205, 205, 205, // 4: 80% all for 5 hours
19, 0, 50, 50, 50, 50, // 5: 20% all 19, 0, 50, 50, 50, 50, // 5: 20% all