mirror of
https://github.com/wled/WLED.git
synced 2025-11-28 04:07:47 +00:00
Compare commits
4 Commits
coderabbit
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
666df7406b | ||
|
|
7dba2465d3 | ||
|
|
6fba6f7562 | ||
|
|
ab6407dd90 |
@@ -8,6 +8,7 @@
|
|||||||
<script>
|
<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 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 customStarts=false,startsDirty=[];
|
||||||
|
var busChanged=false,originalBusTypes=[];
|
||||||
function off(n) { gN(n).value = -1;}
|
function off(n) { gN(n).value = -1;}
|
||||||
// these functions correspond to C macros found in const.h
|
// 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
|
function gT(t) { for (let type of d.ledTypes) if (t == type.i) return type; } // getType from available ledTypes
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
}, ()=>{
|
}, ()=>{
|
||||||
checkSi();
|
checkSi();
|
||||||
setABL();
|
setABL();
|
||||||
|
captureInitialBusState(); // capture initial bus configuration
|
||||||
d.Sf.addEventListener("submit", trySubmit);
|
d.Sf.addEventListener("submit", trySubmit);
|
||||||
if (d.um_p[0]==-1) d.um_p.shift();
|
if (d.um_p[0]==-1) d.um_p.shift();
|
||||||
pinDropdowns();
|
pinDropdowns();
|
||||||
@@ -112,6 +114,23 @@
|
|||||||
d.Sf.data.value = '';
|
d.Sf.data.value = '';
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!pinsOK()) {e.stopPropagation();return false;} // Prevent form submission and contact with server
|
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 changed. Reboot required to apply changes.\n\nContinue 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;}
|
if (bquot > 200) {var msg = "Too many LEDs! Can't handle that!"; alert(msg); e.stopPropagation(); return false;}
|
||||||
else {
|
else {
|
||||||
if (bquot > 80) {var msg = "Memory usage is high, reboot recommended!\n\rSet transitions to 0 to save memory.";
|
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 dC = 0; // count of digital buses (for parallel I2S)
|
||||||
let LTs = d.Sf.querySelectorAll("#mLC select[name^=LT]");
|
let LTs = d.Sf.querySelectorAll("#mLC select[name^=LT]");
|
||||||
LTs.forEach((s,i)=>{
|
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?
|
// is the field a LED type?
|
||||||
var n = s.name.substring(2,3); // bus number (0-Z)
|
var n = s.name.substring(2,3); // bus number (0-Z)
|
||||||
var t = parseInt(s.value);
|
var t = parseInt(s.value);
|
||||||
@@ -467,7 +486,7 @@
|
|||||||
var cn = `<div class="iST">
|
var cn = `<div class="iST">
|
||||||
<hr class="sml">
|
<hr class="sml">
|
||||||
${i+1}:
|
${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}">
|
<div id="abl${s}">
|
||||||
mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();">
|
mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();">
|
||||||
<option value="55" selected>55mA (typ. 5V WS281x)</option>
|
<option value="55" selected>55mA (typ. 5V WS281x)</option>
|
||||||
@@ -540,6 +559,7 @@ mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();">
|
|||||||
gId("-").style.display = (i>0) ? "inline":"none";
|
gId("-").style.display = (i>0) ? "inline":"none";
|
||||||
|
|
||||||
if (!init) {
|
if (!init) {
|
||||||
|
checkBusChanges(); // check if bus count changed
|
||||||
UI();
|
UI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -634,6 +654,32 @@ Swap: <select id="xw${s}" name="XW${s}">
|
|||||||
gId("si").checked = cs;
|
gId("si").checked = cs;
|
||||||
tglSi(cs);
|
tglSi(cs);
|
||||||
}
|
}
|
||||||
|
function captureInitialBusState() {
|
||||||
|
// capture initial bus types
|
||||||
|
let buses = d.Sf.querySelectorAll("#mLC select[name^=LT]");
|
||||||
|
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]");
|
||||||
|
|
||||||
|
// check if any bus type changed (excluding virtual and network buses)
|
||||||
|
for (let i = 0; i < buses.length; i++) {
|
||||||
|
let oldType = originalBusTypes[i] || 0;
|
||||||
|
let newType = parseInt(buses[i].value) || 0;
|
||||||
|
if (oldType != newType) {
|
||||||
|
// only flag for reboot if neither old nor new type is virtual/network
|
||||||
|
if (!isVir(oldType) && !isNet(oldType) && !isVir(newType) && !isNet(newType)) {
|
||||||
|
busChanged = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// https://stackoverflow.com/questions/7346563/loading-local-json-file
|
// https://stackoverflow.com/questions/7346563/loading-local-json-file
|
||||||
function loadCfg(o) {
|
function loadCfg(o) {
|
||||||
var f, fr;
|
var f, fr;
|
||||||
|
|||||||
@@ -364,6 +364,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
if (t > 0) briMultiplier = t;
|
if (t > 0) briMultiplier = t;
|
||||||
|
|
||||||
doInitBusses = busesChanged;
|
doInitBusses = busesChanged;
|
||||||
|
|
||||||
|
// handle reboot request for bus changes
|
||||||
|
if (request->hasArg(F("RBT"))) doReboot = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//UI
|
//UI
|
||||||
|
|||||||
Reference in New Issue
Block a user