Added a slider for each light to show pwm state
This commit is contained in:
parent
ad31eb0748
commit
26d43a6070
2 changed files with 31 additions and 3 deletions
|
@ -593,7 +593,10 @@ void init_webserver()
|
||||||
http_content += "<div class=\"pure-control-group\">";
|
http_content += "<div class=\"pure-control-group\">";
|
||||||
http_content += "<label for=\"bri\"" + (String)light_num + ">Bri</label>";
|
http_content += "<label for=\"bri\"" + (String)light_num + ">Bri</label>";
|
||||||
http_content += "<input id=\"bri" + (String)light_num + "\" onchange=\"sendSliderValue(" + (String)(light_num+1) + ")\" name=\"bri" + (String)light_num + "\" type=\"range\" min=\"0\" max=\"255\" value=\"" + (String)bri[light_num] + "\">";
|
http_content += "<input id=\"bri" + (String)light_num + "\" onchange=\"sendSliderValue(" + (String)(light_num+1) + ")\" name=\"bri" + (String)light_num + "\" type=\"range\" min=\"0\" max=\"255\" value=\"" + (String)bri[light_num] + "\">";
|
||||||
http_content += "<label id=\"bri" + (String)light_num + "_val\" name=\"bri" + (String)light_num + "\">" + (String)(int)(bri[light_num] * 100.0 / 255.0) + "</label>%";
|
http_content += " <span id=\"bri" + (String)light_num + "_val\" name=\"bri" + (String)light_num + "\">" + (String)(int)(bri[light_num] * 100.0 / 255.0) + "</span>%";
|
||||||
|
http_content += "<label for=\"light" + (String)light_num + "_pwm\">PWM-Wert</label>";
|
||||||
|
http_content += "<input type=\"range\" min=\"0\" max=\"383\" value=\"0\" id=\"light" + (String)light_num + "_pwm\" disabled>";
|
||||||
|
http_content += " <span id=\"light" + (String)light_num + "_pwm_txt\"></span>";
|
||||||
http_content += "<script>";
|
http_content += "<script>";
|
||||||
http_content += "var slider" + (String)light_num + " = document.getElementById(\"bri" + (String)light_num + "\");";
|
http_content += "var slider" + (String)light_num + " = document.getElementById(\"bri" + (String)light_num + "\");";
|
||||||
http_content += "var output" + (String)light_num + " = document.getElementById(\"bri" + (String)light_num + "\_val\");";
|
http_content += "var output" + (String)light_num + " = document.getElementById(\"bri" + (String)light_num + "\_val\");";
|
||||||
|
@ -602,6 +605,7 @@ void init_webserver()
|
||||||
http_content += "output" + (String)light_num + ".innerHTML = (Math.round((this.value * 100.0 / 255.0) * 100) / 100).toFixed(2);";
|
http_content += "output" + (String)light_num + ".innerHTML = (Math.round((this.value * 100.0 / 255.0) * 100) / 100).toFixed(2);";
|
||||||
http_content += "}";
|
http_content += "}";
|
||||||
http_content += "</script>";
|
http_content += "</script>";
|
||||||
|
|
||||||
http_content += "</div>";
|
http_content += "</div>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -859,6 +863,30 @@ void init_webserver()
|
||||||
"}"
|
"}"
|
||||||
"setInterval(updateLightState, 10000);"
|
"setInterval(updateLightState, 10000);"
|
||||||
"updateLightState();"
|
"updateLightState();"
|
||||||
|
|
||||||
|
// show pwm values in webinterface
|
||||||
|
"function updatePWMValues() {"
|
||||||
|
"for (let i = 0; i < " + (String)LIGHTS_COUNT + "; i++) {"
|
||||||
|
"const lightID = i + 1;"
|
||||||
|
"const pwmElement = document.getElementById(`light${i}_pwm`);"
|
||||||
|
"const pwmElementTxt = document.getElementById(`light${i}_pwm_txt`);"
|
||||||
|
"if (pwmElement) {"
|
||||||
|
"const url = `http://192.168.0.26/state?light=${lightID}`;"
|
||||||
|
"fetch(url)"
|
||||||
|
".then(response => response.json())"
|
||||||
|
".then(data => {"
|
||||||
|
"const pwmValue = data.curpwm - 640;"
|
||||||
|
//"console.log('curpwm[' + i + '] = ' + data.curpwm);"
|
||||||
|
"pwmElement.innerText = pwmValue.toString();"
|
||||||
|
"pwmElement.value = pwmValue;"
|
||||||
|
"pwmElementTxt.innerText = pwmValue.toString();"
|
||||||
|
"})"
|
||||||
|
".catch(error => console.error(error));"
|
||||||
|
"}"
|
||||||
|
"}"
|
||||||
|
"}"
|
||||||
|
"updatePWMValues();"
|
||||||
|
"setInterval(updatePWMValues, 5000);"
|
||||||
"</script>";
|
"</script>";
|
||||||
|
|
||||||
#endif // DISABLE_WEB_CONTROL
|
#endif // DISABLE_WEB_CONTROL
|
||||||
|
|
|
@ -251,9 +251,9 @@ void tc_update_main()
|
||||||
if (target_data_block > 0)
|
if (target_data_block > 0)
|
||||||
{
|
{
|
||||||
// hours as seconds from now on to the next enabled block
|
// hours as seconds from now on to the next enabled block
|
||||||
t_time = ((uint16_t)tc_data[target_data_block].hh * 60 * 60) - ((uint16_t)timeClient.getHours() * 60 * 60);
|
t_time = ((uint16_t)tc_data[target_data_block].hh * 60 * 60) - ((uint16_t)hour() * 60 * 60);
|
||||||
// add the left over seconds to the next enabled block
|
// add the left over seconds to the next enabled block
|
||||||
t_time += ((uint16_t)tc_data[target_data_block].mm * 60) - ((uint16_t)timeClient.getMinutes() * 60);
|
t_time += ((uint16_t)tc_data[target_data_block].mm * 60) - ((uint16_t)minute() * 60);
|
||||||
|
|
||||||
}
|
}
|
||||||
transitiontime[0] = t_time;
|
transitiontime[0] = t_time;
|
||||||
|
|
Loading…
Reference in a new issue