Compare commits

...

4 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
666df7406b Remove unused originalBusCount variable
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
2025-09-28 12:44:57 +00:00
copilot-swe-agent[bot]
7dba2465d3 Address review comments: remove redundant bus count check, exempt virtual/network buses, shorten dialog message
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
2025-09-28 10:58:46 +00:00
copilot-swe-agent[bot]
6fba6f7562 Remove bus type restrictions and add reboot handling for LED settings
Co-authored-by: DedeHai <6280424+DedeHai@users.noreply.github.com>
2025-09-28 06:46:39 +00:00
copilot-swe-agent[bot]
ab6407dd90 Initial plan 2025-09-28 06:26:02 +00:00
2 changed files with 51 additions and 2 deletions

View File

@@ -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,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 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;}
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 @@ mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();">
gId("-").style.display = (i>0) ? "inline":"none";
if (!init) {
checkBusChanges(); // check if bus count changed
UI();
}
}
@@ -634,6 +654,32 @@ Swap: <select id="xw${s}" name="XW${s}">
gId("si").checked = 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
function loadCfg(o) {
var f, fr;

View File

@@ -364,6 +364,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (t > 0) briMultiplier = t;
doInitBusses = busesChanged;
// handle reboot request for bus changes
if (request->hasArg(F("RBT"))) doReboot = true;
}
//UI