Fixed pwm value output - as % now.
This commit is contained in:
parent
26d43a6070
commit
e3454e7e10
1 changed files with 5 additions and 5 deletions
|
@ -594,9 +594,9 @@ void init_webserver()
|
||||||
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 += " <span id=\"bri" + (String)light_num + "_val\" name=\"bri" + (String)light_num + "\">" + (String)(int)(bri[light_num] * 100.0 / 255.0) + "</span>%";
|
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 += "<br><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 += "<input type=\"range\" min=\"0\" max=\"100\" value=\"0\" id=\"light" + (String)light_num + "_pwm\" disabled>";
|
||||||
http_content += " <span id=\"light" + (String)light_num + "_pwm_txt\"></span>";
|
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\");";
|
||||||
|
@ -875,8 +875,8 @@ void init_webserver()
|
||||||
"fetch(url)"
|
"fetch(url)"
|
||||||
".then(response => response.json())"
|
".then(response => response.json())"
|
||||||
".then(data => {"
|
".then(data => {"
|
||||||
"const pwmValue = data.curpwm - 640;"
|
"const pwmValue = ((Math.round((data.curpwm - ((data.curpwm >= 640.0) ? 640.0 : 0)) / 383.0 * 100.0) * 100.0) / 100.0).toFixed(2);" // pwm as % 640 to 1023
|
||||||
//"console.log('curpwm[' + i + '] = ' + data.curpwm);"
|
"console.log('curpwm[' + i + '] = ' + data.curpwm + ' = ' + pwmValue);"
|
||||||
"pwmElement.innerText = pwmValue.toString();"
|
"pwmElement.innerText = pwmValue.toString();"
|
||||||
"pwmElement.value = pwmValue;"
|
"pwmElement.value = pwmValue;"
|
||||||
"pwmElementTxt.innerText = pwmValue.toString();"
|
"pwmElementTxt.innerText = pwmValue.toString();"
|
||||||
|
|
Loading…
Reference in a new issue