Compare commits

...

5 Commits

Author SHA1 Message Date
Frank
54b7dfe04b Fix debug message for servicing wait
forgot to adjust the debug condition in my previous commit.

NB: the condition only shows a debug message when the max wait time was exceeded, which can only happen when line 1692 has waited for the maximum allowed time. ->Is this intended?
2025-11-18 23:05:03 +01:00
Frank
4a33809d66 make waitForIt() timing logic robust against millis() rollover
the timing logic did not work in case that millis()+100 + frametime rolls over; in this case millis() > maxWait, and waiting would be skipped which might lead to crashes.
-> logic slightly adjusted to be robust against rollover.
2025-11-18 22:56:30 +01:00
Damian Schneider
336e074b4a fix for 0byte size files, also made reading ledmaps more efficient
when a ledmap is read from a file, it first parses the keys, putting the in front is more efficient as it will find them in the first 256 byte chunk.
2025-11-18 20:40:04 +01:00
Damian Schneider
aaad450175 show minimum of 0.1KB for small files in file editor 2025-11-18 07:26:17 +01:00
Damian Schneider
65c43b5224 add ctrl+s support to file editor, also add toast instead of alert 2025-11-17 20:56:49 +01:00
2 changed files with 18 additions and 9 deletions

View File

@@ -1687,10 +1687,11 @@ void WS2812FX::setTransitionMode(bool t) {
// rare circumstances are: setting FPS to high number (i.e. 120) and have very slow effect that will need more
// time than 2 * _frametime (1000/FPS) to draw content
void WS2812FX::waitForIt() {
unsigned long maxWait = millis() + 2*getFrameTime() + 100; // TODO: this needs a proper fix for timeout! see #4779
while (isServicing() && maxWait > millis()) delay(1);
unsigned long waitStart = millis();
unsigned long maxWait = 2*getFrameTime() + 100; // TODO: this needs a proper fix for timeout! see #4779
while (isServicing() && (millis() - waitStart < maxWait)) delay(1); // safe even when millis() rolls over
#ifdef WLED_DEBUG
if (millis() >= maxWait) DEBUG_PRINTLN(F("Waited for strip to finish servicing."));
if (millis()-waitStart >= maxWait) DEBUG_PRINTLN(F("Waited for strip to finish servicing."));
#endif
};

View File

@@ -213,7 +213,7 @@ function createTop(element, editor){
function httpPostCb(st,resp){
if (st!=200) alert("ERROR "+st+": "+resp);
else {
alert("Upload successful!");
showToast("Upload successful!");
refreshTree();
}
}
@@ -264,7 +264,7 @@ function createTree(element, editor){
leaf.textContent=name;
var span = cE("span");
span.style.cssText = "font-size: 14px; color: #aaa; margin-left: 8px;";
span.textContent = (size / 1024).toFixed(1) + "KB";
span.textContent = (size > 0 ? Math.max(0.1, (size / 1024)).toFixed(1) : 0) + "KB"; // show size in KB, minimum 0.1 to not show 0KB for small files
leaf.appendChild(span);
leaf.onmouseover=function(){ leaf.style.background="#333"; };
leaf.onmouseout=function(){ leaf.style.background=""; };
@@ -377,13 +377,13 @@ function prettyLedmap(json){
rows.push(" " + obj.map.slice(i, i + width).map(pad).join(", "));
}
let pretty = "{\n \"map\": [\n" + rows.join(",\n") + "\n ]";
let pretty = "{\n";
for (let k of Object.keys(obj)) {
if (k !== "map") {
pretty += ",\n \"" + k + "\": " + JSON.stringify(obj[k]);
pretty += " \"" + k + "\": " + JSON.stringify(obj[k]) + ",\n"; // print all keys first (speeds up loading)
}
}
pretty += "\n}";
pretty += " \"map\": [\n" + rows.join(",\n") + "\n ]\n}";
return pretty;
} catch (e) {
return json;
@@ -493,7 +493,7 @@ function createEditor(element,file){
req.add("POST","/upload",fd,function(st,resp){
if (st!=200) alert("ERROR "+st+": "+resp);
else {
alert("File saved successfully!");
showToast("File saved");
refreshTree();
}
});
@@ -567,10 +567,18 @@ function onBodyLoad(){
var editor=createEditor("editor",vars.file);
globalTree=createTree("tree",editor);
createTop("top",editor);
// Add Ctrl+S / Cmd+S override to save the file
document.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
editor.save();
}
});
}
</script>
</head>
<body onload="onBodyLoad()">
<div id="toast"></div>
<div id="loader"><div class="loader"></div></div>
<div id="top"></div>
<div style="flex:1;position:relative">