Skip to content

Commit

Permalink
Fixed iOS LED settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Aircoookie committed Apr 2, 2021
1 parent 8755a9b commit fbe8661
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## WLED changelog

### WLED release 0.12.0

#### Build 2103310

- Version bump to 0.12.0 "Hikari"
- Fixed LED settings submission in iOS app

### Development versions between 0.11.1 and 0.12.0 releases

#### Build 2103300
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wled",
"version": "0.12.0-b5",
"version": "0.12.0",
"description": "Tools for WLED project",
"main": "tools/cdata.js",
"directories": {
Expand Down
10 changes: 6 additions & 4 deletions wled00/data/settings_leds.htm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
function bLimits(b,p,m) {
maxB = b; maxM = m; maxPB = p;
}
function trySubmit() {
function trySubmit(event) {
event.preventDefault();
var LCs = d.getElementsByTagName("input");
for (i=0; i<LCs.length; i++) {
var nm = LCs[i].name.substring(0,2);
Expand All @@ -36,6 +37,7 @@
}
}
if (bquot > 100) {var msg = "Too many LEDs for me to handle!"; if (maxM < 10000) msg += " Consider using an ESP32."; alert(msg); return;}
if (d.Sf.checkValidity()) d.Sf.submit(); //https://stackoverflow.com/q/37323914
if (d.Sf.reportValidity()) d.Sf.submit();
}
function S(){GetV();setABL();}
Expand Down Expand Up @@ -255,9 +257,9 @@
</style>
</head>
<body onload="S()">
<form id="form_s" name="Sf" method="post">
<form id="form_s" name="Sf" method="post" onsubmit="trySubmit(event)">
<div class="helpB"><button type="button" onclick="H()">?</button></div>
<button type="button" onclick="B()">Back</button><button type="button" onclick="trySubmit()">Save</button><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>LED &amp; Hardware setup</h2>
Total LED count: <input name="LC" type="number" min="1" max="8192" oninput="UI()" required><br>
<i>Recommended power supply for brightest white:</i><br>
Expand Down Expand Up @@ -344,7 +346,7 @@ <h3>Advanced</h3>
<option value=4>Legacy</option>
</select>
<br></span><hr>
<button type="button" onclick="B()">Back</button><button type="button" onclick="trySubmit()">Save</button>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>
</html>
2 changes: 1 addition & 1 deletion wled00/html_other.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function B(){window.history.back()}function U(){document.getElementById("uf").st
.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%}#msg{display:none}
</style></head><body><h2>WLED Software Update</h2><form method="POST"
action="/update" id="uf" enctype="multipart/form-data" onsubmit="U()">
Installed version: 0.12.0-b5<br>Download the latest binary: <a
Installed version: 0.12.0<br>Download the latest binary: <a
href="https://github.com/Aircoookie/WLED/releases" target="_blank"><img
src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square">
</a><br><input type="file" class="bt" name="update" accept=".bin" required><br>
Expand Down
16 changes: 8 additions & 8 deletions wled00/html_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ Do not enable if WiFi is working correctly, increases power consumption.</i><div
// Autogenerated from wled00/data/settings_leds.htm, do not edit!!
const char PAGE_settings_leds[] PROGMEM = R"=====(<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta
name="viewport" content="width=500"><title>LED Settings</title><script>
var d=document,laprev=55,maxB=1,maxM=5e3,maxPB=4096,bquot=0;function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings")}function B(){window.open("/settings","_self")}function bLimits(e,n,t){maxB=e,maxM=t,maxPB=n}function trySubmit(){var e=d.getElementsByTagName("input");for(i=0;i<e.length;i++){var n=e[i].name.substring(0,2);if(("L0"==n||"L1"==n||"RL"==n||"BT"==n||"IR"==n||"AX"==n)&&""!=e[i].value&&"-1"!=e[i].value){if(e[i].value>5&&e[i].value<12)return alert("Sorry, pins 6-11 can not be used."),void e[i].focus();if(d.um_p&&d.um_p.some(n=>n==parseInt(e[i].value,10)))return alert("Usermod pin conflict!"),void e[i].focus();for(j=i+1;j<e.length;j++){var t=e[j].name.substring(0,2);if(("L0"==t||"L1"==t||"RL"==t||"BT"==t||"IR"==t||"AX"==t)&&""!=e[j].value&&e[i].value==e[j].value)return alert("Pin conflict!"),void e[i].focus()}}}if(bquot>100){var a="Too many LEDs for me to handle!";return maxM<1e4&&(a+=" Consider using an ESP32."),void alert(a)}d.Sf.reportValidity()&&d.Sf.submit()}function S(){GetV(),setABL()}function enABL(){var e=d.getElementById("able").checked;d.Sf.LA.value=e?laprev:0,d.getElementById("abl").style.display=e?"inline":"none",d.getElementById("psu2").style.display=e?"inline":"none",d.Sf.LA.value>0&&setABL()}function enLA(){var e=d.Sf.LAsel.value;d.Sf.LA.value=e,d.getElementById("LAdis").style.display=50==e?"inline":"none",UI()}function setABL(){switch(d.getElementById("able").checked=!0,d.Sf.LAsel.value=50,parseInt(d.Sf.LA.value)){case 0:d.getElementById("able").checked=!1,enABL();break;case 30:d.Sf.LAsel.value=30;break;case 35:d.Sf.LAsel.value=35;break;case 55:d.Sf.LAsel.value=55;break;case 255:d.Sf.LAsel.value=255;break;default:d.getElementById("LAdis").style.display="inline"}d.getElementById("m1").innerHTML=maxM,UI()}function getMem(e,n,t){return e<32?maxM<1e4&&3==t?e>29?20*n:15*n:maxM>=1e4?e>29?8*n:6*n:e>29?4*n:3*n:e>31&&e<48?5:44==e||45==e?4*n:3*n}function UI(){var e=!1,t=0;d.getElementById("ampwarning").style.display=d.Sf.MA.value>7200?"inline":"none",255==d.Sf.LA.value?laprev=12:d.Sf.LA.value>0&&(laprev=d.Sf.LA.value);var i=d.getElementsByTagName("select");for(u=0;u<i.length;u++)if("LT"==i[u].name.substring(0,2)){n=i[u].name.substring(2);var a=i[u].value;d.getElementById("p0d"+n).innerHTML=a>49?"Data pin:":a>41?"Pins:":"Pin:",d.getElementById("p1d"+n).innerHTML=a>49?"Clk:":"";var l=d.getElementsByName("L1"+n)[0];for(t+=getMem(a,d.getElementsByName("LC"+n)[0].value,d.getElementsByName("L0"+n)[0].value),p=1;p<5;p++){(l=d.getElementsByName("L"+p+n)[0])&&(a>49&&1==p||a>41&&a<50&&p+40<a?(l.style.display="inline",l.required=!0):(l.style.display="none",l.required=!1,l.value=""))}(30==a||31==a||a>40&&a<46&&43!=a)&&(e=!0),d.getElementById("dig"+n).style.display=a>31&&a<48?"none":"inline",d.getElementById("psd"+n).innerHTML=a>31&&a<48?"Index:":"Start:"}var o=d.querySelectorAll(".wc"),s=o.length;for(u=0;u<s;u++)o[u].style.display=e?"inline":"none";if(d.activeElement==d.getElementsByName("LC")[0]){var u=d.getElementsByClassName("iST").length;1==u&&(d.getElementsByName("LC0")[0].value=d.getElementsByName("LC")[0].value)}var r=d.getElementsByTagName("input"),m=0,v=0;for(u=0;u<r.length;u++){if("LC"!=r[u].name.substring(0,2)||"LC"==r[u].name);else{var y=parseInt(r[u].value,10);y&&(m+=y,y>v&&(v=y))}}d.getElementById("m0").innerHTML=t,bquot=t/maxM*100,d.getElementById("dbar").style.background=`linear-gradient(90deg, ${bquot>60?bquot>90?"red":"orange":"#ccc"} 0 ${bquot}%%, #444 ${bquot}%% 100%%)`,d.getElementById("ledwarning").style.display=v>800||bquot>80?"inline":"none",d.getElementById("wreason").innerHTML=bquot>80?"than 60%% of max. LED memory":"800 LEDs per pin";var g=Math.ceil((100+m*laprev)/500)/2;g=g>5?Math.ceil(g):g;i="";var L=30==d.Sf.LAsel.value,B=255==d.Sf.LAsel.value;g<1.02&&!L&&!B?i="ESP 5V pin with 1A USB supply":(i+=L?"12V ":B?"WS2815 12V ":"5V ",i+=g,i+="A supply connected to LEDs");var c=Math.ceil((100+m*laprev)/1500)/2,f="(for most effects, ~";f+=c=c>5?Math.ceil(c):c,f+="A is enough)<br>",d.getElementById("psu").innerHTML=i,d.getElementById("psu2").innerHTML=B?"":f}function lastEnd(e){return e<1?0:(v=parseInt(d.getElementsByName("LS"+(e-1))[0].value)+parseInt(d.getElementsByName("LC"+(e-1))[0].value),isNaN(v)?0:v)}function addLEDs(e){if(e>1)return maxB=e,void(d.getElementById("+").style.display="inline");var n=d.getElementsByClassName("iST"),t=n.length;if(!(1==e&&t>=maxB||-1==e&&0==t)){var i=d.getElementById("mLC");if(1==e){var a=`<div class="iST">\n ${t>0?'<hr style="width:260px">':""}\n ${t+1}:\n <select name="LT${t}" onchange="UI()">\n <option value="22">WS281x</option>\n <option value="30">SK6812 RGBW</option>\n <option value="31">TM1814</option>\n <option value="24">400kHz</option>\n <option value="50">WS2801</option>\n <option value="51">APA102</option>\n <option value="52">LPD8806</option>\n <option value="53">P9813</option>\n <option value="41">PWM White</option>\n <option value="42">PWM WWCW</option>\n <option value="43">PWM RGB</option>\n <option value="44">PWM RGBW</option>\n <option value="45">PWM RGBWC</option>\n </select>&nbsp;\n Color Order:\n <select name="CO${t}">\n <option value="0">GRB</option>\n <option value="1">RGB</option>\n <option value="2">BRG</option>\n <option value="3">RBG</option>\n <option value="4">BGR</option>\n <option value="5">GBR</option>\n </select><br>\n <span id="p0d${t}">Pin:</span> <input type="number" name="L0${t}" min="0" max="40" required style="width:35px" oninput="UI()"/>\n <span id="p1d${t}">Clock:</span> <input type="number" name="L1${t}" min="0" max="40" style="width:35px"/>\n <span id="p2d${t}"></span><input type="number" name="L2${t}" min="0" max="40" style="width:35px"/>\n <span id="p3d${t}"></span><input type="number" name="L3${t}" min="0" max="40" style="width:35px"/>\n <span id="p4d${t}"></span><input type="number" name="L4${t}" min="0" max="40" style="width:35px"/>\n <br>\n <span id="psd${t}">Start:</span> <input type="number" name="LS${t}" min="0" max="8191" value="${lastEnd(t)}" required />&nbsp;\n <div id="dig${t}" style="display:inline">\n Count: <input type="number" name="LC${t}" min="0" max="${maxPB}" value="1" required oninput="UI()" /><br></div>\n Reverse: <input type="checkbox" name="CV${t}"><br>\n </div>`;i.insertAdjacentHTML("beforeend",a)}-1==e&&(n[--t].remove(),--t),d.getElementById("+").style.display=t<maxB-1?"inline":"none",d.getElementById("-").style.display=t>0?"inline":"none",UI()}}function GetV() {var d=document;
var d=document,laprev=55,maxB=1,maxM=5e3,maxPB=4096,bquot=0;function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings")}function B(){window.open("/settings","_self")}function bLimits(e,n,t){maxB=e,maxM=t,maxPB=n}function trySubmit(e){e.preventDefault();var n=d.getElementsByTagName("input");for(i=0;i<n.length;i++){var t=n[i].name.substring(0,2);if(("L0"==t||"L1"==t||"RL"==t||"BT"==t||"IR"==t||"AX"==t)&&""!=n[i].value&&"-1"!=n[i].value){if(n[i].value>5&&n[i].value<12)return alert("Sorry, pins 6-11 can not be used."),void n[i].focus();if(d.um_p&&d.um_p.some(e=>e==parseInt(n[i].value,10)))return alert("Usermod pin conflict!"),void n[i].focus();for(j=i+1;j<n.length;j++){var a=n[j].name.substring(0,2);if(("L0"==a||"L1"==a||"RL"==a||"BT"==a||"IR"==a||"AX"==a)&&""!=n[j].value&&n[i].value==n[j].value)return alert("Pin conflict!"),void n[i].focus()}}}if(bquot>100){var l="Too many LEDs for me to handle!";return maxM<1e4&&(l+=" Consider using an ESP32."),void alert(l)}d.Sf.checkValidity()&&d.Sf.submit(),d.Sf.reportValidity()&&d.Sf.submit()}function S(){GetV(),setABL()}function enABL(){var e=d.getElementById("able").checked;d.Sf.LA.value=e?laprev:0,d.getElementById("abl").style.display=e?"inline":"none",d.getElementById("psu2").style.display=e?"inline":"none",d.Sf.LA.value>0&&setABL()}function enLA(){var e=d.Sf.LAsel.value;d.Sf.LA.value=e,d.getElementById("LAdis").style.display=50==e?"inline":"none",UI()}function setABL(){switch(d.getElementById("able").checked=!0,d.Sf.LAsel.value=50,parseInt(d.Sf.LA.value)){case 0:d.getElementById("able").checked=!1,enABL();break;case 30:d.Sf.LAsel.value=30;break;case 35:d.Sf.LAsel.value=35;break;case 55:d.Sf.LAsel.value=55;break;case 255:d.Sf.LAsel.value=255;break;default:d.getElementById("LAdis").style.display="inline"}d.getElementById("m1").innerHTML=maxM,UI()}function getMem(e,n,t){return e<32?maxM<1e4&&3==t?e>29?20*n:15*n:maxM>=1e4?e>29?8*n:6*n:e>29?4*n:3*n:e>31&&e<48?5:44==e||45==e?4*n:3*n}function UI(){var e=!1,t=0;d.getElementById("ampwarning").style.display=d.Sf.MA.value>7200?"inline":"none",255==d.Sf.LA.value?laprev=12:d.Sf.LA.value>0&&(laprev=d.Sf.LA.value);var i=d.getElementsByTagName("select");for(u=0;u<i.length;u++)if("LT"==i[u].name.substring(0,2)){n=i[u].name.substring(2);var a=i[u].value;d.getElementById("p0d"+n).innerHTML=a>49?"Data pin:":a>41?"Pins:":"Pin:",d.getElementById("p1d"+n).innerHTML=a>49?"Clk:":"";var l=d.getElementsByName("L1"+n)[0];for(t+=getMem(a,d.getElementsByName("LC"+n)[0].value,d.getElementsByName("L0"+n)[0].value),p=1;p<5;p++){(l=d.getElementsByName("L"+p+n)[0])&&(a>49&&1==p||a>41&&a<50&&p+40<a?(l.style.display="inline",l.required=!0):(l.style.display="none",l.required=!1,l.value=""))}(30==a||31==a||a>40&&a<46&&43!=a)&&(e=!0),d.getElementById("dig"+n).style.display=a>31&&a<48?"none":"inline",d.getElementById("psd"+n).innerHTML=a>31&&a<48?"Index:":"Start:"}var o=d.querySelectorAll(".wc"),s=o.length;for(u=0;u<s;u++)o[u].style.display=e?"inline":"none";if(d.activeElement==d.getElementsByName("LC")[0]){var u=d.getElementsByClassName("iST").length;1==u&&(d.getElementsByName("LC0")[0].value=d.getElementsByName("LC")[0].value)}var r=d.getElementsByTagName("input"),m=0,v=0;for(u=0;u<r.length;u++){if("LC"!=r[u].name.substring(0,2)||"LC"==r[u].name);else{var y=parseInt(r[u].value,10);y&&(m+=y,y>v&&(v=y))}}d.getElementById("m0").innerHTML=t,bquot=t/maxM*100,d.getElementById("dbar").style.background=`linear-gradient(90deg, ${bquot>60?bquot>90?"red":"orange":"#ccc"} 0 ${bquot}%%, #444 ${bquot}%% 100%%)`,d.getElementById("ledwarning").style.display=v>800||bquot>80?"inline":"none",d.getElementById("wreason").innerHTML=bquot>80?"than 60%% of max. LED memory":"800 LEDs per pin";var g=Math.ceil((100+m*laprev)/500)/2;g=g>5?Math.ceil(g):g;i="";var L=30==d.Sf.LAsel.value,f=255==d.Sf.LAsel.value;g<1.02&&!L&&!f?i="ESP 5V pin with 1A USB supply":(i+=L?"12V ":f?"WS2815 12V ":"5V ",i+=g,i+="A supply connected to LEDs");var B=Math.ceil((100+m*laprev)/1500)/2,c="(for most effects, ~";c+=B=B>5?Math.ceil(B):B,c+="A is enough)<br>",d.getElementById("psu").innerHTML=i,d.getElementById("psu2").innerHTML=f?"":c}function lastEnd(e){return e<1?0:(v=parseInt(d.getElementsByName("LS"+(e-1))[0].value)+parseInt(d.getElementsByName("LC"+(e-1))[0].value),isNaN(v)?0:v)}function addLEDs(e){if(e>1)return maxB=e,void(d.getElementById("+").style.display="inline");var n=d.getElementsByClassName("iST"),t=n.length;if(!(1==e&&t>=maxB||-1==e&&0==t)){var i=d.getElementById("mLC");if(1==e){var a=`<div class="iST">\n ${t>0?'<hr style="width:260px">':""}\n ${t+1}:\n <select name="LT${t}" onchange="UI()">\n <option value="22">WS281x</option>\n <option value="30">SK6812 RGBW</option>\n <option value="31">TM1814</option>\n <option value="24">400kHz</option>\n <option value="50">WS2801</option>\n <option value="51">APA102</option>\n <option value="52">LPD8806</option>\n <option value="53">P9813</option>\n <option value="41">PWM White</option>\n <option value="42">PWM WWCW</option>\n <option value="43">PWM RGB</option>\n <option value="44">PWM RGBW</option>\n <option value="45">PWM RGBWC</option>\n </select>&nbsp;\n Color Order:\n <select name="CO${t}">\n <option value="0">GRB</option>\n <option value="1">RGB</option>\n <option value="2">BRG</option>\n <option value="3">RBG</option>\n <option value="4">BGR</option>\n <option value="5">GBR</option>\n </select><br>\n <span id="p0d${t}">Pin:</span> <input type="number" name="L0${t}" min="0" max="40" required style="width:35px" oninput="UI()"/>\n <span id="p1d${t}">Clock:</span> <input type="number" name="L1${t}" min="0" max="40" style="width:35px"/>\n <span id="p2d${t}"></span><input type="number" name="L2${t}" min="0" max="40" style="width:35px"/>\n <span id="p3d${t}"></span><input type="number" name="L3${t}" min="0" max="40" style="width:35px"/>\n <span id="p4d${t}"></span><input type="number" name="L4${t}" min="0" max="40" style="width:35px"/>\n <br>\n <span id="psd${t}">Start:</span> <input type="number" name="LS${t}" min="0" max="8191" value="${lastEnd(t)}" required />&nbsp;\n <div id="dig${t}" style="display:inline">\n Count: <input type="number" name="LC${t}" min="0" max="${maxPB}" value="1" required oninput="UI()" /><br></div>\n Reverse: <input type="checkbox" name="CV${t}"><br>\n </div>`;i.insertAdjacentHTML("beforeend",a)}-1==e&&(n[--t].remove(),--t),d.getElementById("+").style.display=t<maxB-1?"inline":"none",d.getElementById("-").style.display=t>0?"inline":"none",UI()}}function GetV() {var d=document;
%CSS%%SCSS%</head><body onload="S()"><form
id="form_s" name="Sf" method="post"><div class="helpB"><button type="button"
onclick="H()">?</button></div><button type="button" onclick="B()">Back</button>
<button type="button" onclick="trySubmit()">Save</button><hr><h2>
LED &amp; Hardware setup</h2>Total LED count: <input name="LC" type="number"
min="1" max="8192" oninput="UI()" required><br><i>
id="form_s" name="Sf" method="post" onsubmit="trySubmit(event)"><div
class="helpB"><button type="button" onclick="H()">?</button></div><button
type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>LED &amp; Hardware setup</h2>Total LED count: <input name="LC"
type="number" min="1" max="8192" oninput="UI()" required><br><i>
Recommended power supply for brightest white:</i><br><b><span id="psu">?</span>
</b><br><span id="psu2"><br></span><br>Enable automatic brightness limiter:
<input type="checkbox" name="ABen" onchange="enABL()" id="able"><br><div
Expand Down Expand Up @@ -140,7 +140,7 @@ Auto-calculate white channel from RGB:<br><select name="AW"><option value="0">
None</option><option value="1">Brighter</option><option value="2">Accurate
</option><option value="3">Dual</option><option value="4">Legacy</option>
</select><br></span><hr><button type="button" onclick="B()">Back</button><button
type="button" onclick="trySubmit()">Save</button></form></body></html>)=====";
type="submit">Save</button></form></body></html>)=====";


#ifdef WLED_ENABLE_DMX
Expand Down Expand Up @@ -375,7 +375,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
<h3>Software Update</h3><button type="button" onclick="U()">Manual OTA Update
</button><br>Enable ArduinoOTA: <input type="checkbox" name="AO"><br><h3>About
</h3><a href="https://github.com/Aircoookie/WLED/" target="_blank">WLED</a>
version 0.12.0-b5<br><br><a
version 0.12.0<br><br><a
href="https://github.com/Aircoookie/WLED/wiki/Contributors-and-credits"
target="_blank">Contributors, dependencies and special thanks</a><br>
A huge thank you to everyone who helped me create WLED!<br><br>
Expand Down
6 changes: 3 additions & 3 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
/*
Main sketch, global variable declarations
@title WLED project sketch
@version 0.12.0-b5
@version 0.12.0
@author Christian Schwinne
*/

// version code in format yymmddb (b = daily build)
#define VERSION 2103300
#define VERSION 2103310

//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
Expand Down Expand Up @@ -168,7 +168,7 @@
#endif

// Global Variable definitions
WLED_GLOBAL char versionString[] _INIT("0.12.0-b5");
WLED_GLOBAL char versionString[] _INIT("0.12.0");
#define WLED_CODENAME "Hikari"

// AP and OTA default passwords (for maximum security change them!)
Expand Down

0 comments on commit fbe8661

Please sign in to comment.