-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Remove bus type restrictions and add reboot handling for LED settings #4964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
ab6407d
6fba6f7
7dba246
666df74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| <script> | ||
| var maxB=1,maxD=1,maxA=1,maxV=0,maxM=4000,maxPB=2048,maxL=1664,maxCO=5; //maximum bytes for LED allocation: 4kB for 8266, 32kB for 32 | ||
| var customStarts=false,startsDirty=[]; | ||
| var busChanged=false,originalBusCount=0,originalBusTypes=[]; | ||
| function off(n) { gN(n).value = -1;} | ||
| // these functions correspond to C macros found in const.h | ||
| function gT(t) { for (let type of d.ledTypes) if (t == type.i) return type; } // getType from available ledTypes | ||
|
|
@@ -37,6 +38,7 @@ | |
| }, ()=>{ | ||
| checkSi(); | ||
| setABL(); | ||
| captureInitialBusState(); // capture initial bus configuration | ||
| d.Sf.addEventListener("submit", trySubmit); | ||
| if (d.um_p[0]==-1) d.um_p.shift(); | ||
| pinDropdowns(); | ||
|
|
@@ -112,6 +114,23 @@ | |
| d.Sf.data.value = ''; | ||
| e.preventDefault(); | ||
| if (!pinsOK()) {e.stopPropagation();return false;} // Prevent form submission and contact with server | ||
|
|
||
| // check for bus changes that require reboot | ||
| checkBusChanges(); | ||
| if (busChanged) { | ||
| var msg = "LED hardware configuration changed. A reboot is required for changes to take effect.\n\nDo you want to continue and reboot after saving?"; | ||
| if (!confirm(msg)) { | ||
| e.stopPropagation(); | ||
| return false; | ||
| } | ||
| // set reboot flag | ||
| let rebootField = d.createElement('input'); | ||
| rebootField.type = 'hidden'; | ||
| rebootField.name = 'RBT'; | ||
| rebootField.value = '1'; | ||
| d.Sf.appendChild(rebootField); | ||
| } | ||
|
|
||
| if (bquot > 200) {var msg = "Too many LEDs! Can't handle that!"; alert(msg); e.stopPropagation(); return false;} | ||
| else { | ||
| if (bquot > 80) {var msg = "Memory usage is high, reboot recommended!\n\rSet transitions to 0 to save memory."; | ||
|
|
@@ -270,7 +289,7 @@ | |
| let dC = 0; // count of digital buses (for parallel I2S) | ||
| let LTs = d.Sf.querySelectorAll("#mLC select[name^=LT]"); | ||
| LTs.forEach((s,i)=>{ | ||
| if (i < LTs.length-1) s.disabled = true; // prevent changing type (as we can't update options) | ||
| // no longer disable type changes - allow all bus type changes | ||
| // is the field a LED type? | ||
| var n = s.name.substring(2,3); // bus number (0-Z) | ||
| var t = parseInt(s.value); | ||
|
|
@@ -467,7 +486,7 @@ | |
| var cn = `<div class="iST"> | ||
| <hr class="sml"> | ||
| ${i+1}: | ||
| <select name="LT${s}" onchange="UI(true)"></select><br> | ||
| <select name="LT${s}" onchange="checkBusChanges();UI(true)"></select><br> | ||
| <div id="abl${s}"> | ||
| mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();"> | ||
| <option value="55" selected>55mA (typ. 5V WS281x)</option> | ||
|
|
@@ -540,6 +559,7 @@ | |
| gId("-").style.display = (i>0) ? "inline":"none"; | ||
|
|
||
| if (!init) { | ||
| checkBusChanges(); // check if bus count changed | ||
| UI(); | ||
| } | ||
| } | ||
|
|
@@ -634,6 +654,35 @@ | |
| gId("si").checked = cs; | ||
| tglSi(cs); | ||
| } | ||
| function captureInitialBusState() { | ||
| // capture initial number of buses and their types | ||
| let buses = d.Sf.querySelectorAll("#mLC select[name^=LT]"); | ||
| originalBusCount = buses.length; | ||
| originalBusTypes = []; | ||
| buses.forEach((s) => { | ||
| originalBusTypes.push(parseInt(s.value)); | ||
| }); | ||
| busChanged = false; | ||
| } | ||
| function checkBusChanges() { | ||
| // check if bus configuration has changed | ||
| let buses = d.Sf.querySelectorAll("#mLC select[name^=LT]"); | ||
| let currentBusCount = buses.length; | ||
|
||
|
|
||
| // check if bus count changed | ||
| if (currentBusCount != originalBusCount) { | ||
| busChanged = true; | ||
| return; | ||
| } | ||
|
|
||
| // check if any bus type changed | ||
| for (let i = 0; i < buses.length; i++) { | ||
| if (parseInt(buses[i].value) != originalBusTypes[i]) { | ||
|
||
| busChanged = true; | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| // https://stackoverflow.com/questions/7346563/loading-local-json-file | ||
| function loadCfg(o) { | ||
| var f, fr; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shorten the string but keep the meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shortened the confirmation message to "LED hardware changed. Reboot required to apply changes.\n\nContinue and reboot after saving?" while keeping the meaning clear. Fixed in commit 7dba246.