[ai] refactorings

This commit is contained in:
2025-11-02 13:07:52 +01:00
parent 7f120ae62d
commit 83e51e87fe
3 changed files with 18 additions and 13 deletions

View File

@@ -540,6 +540,10 @@ DirectoryNode *DirectoryNode::advanceToNextMP3(const String *currentGlobal)
void DirectoryNode::streamDirectoryHTML(Print &out) const {
#ifdef DEBUG
Serial.printf("StreamDirectoryHTML name=%s numOfFiles=%i\n", name, mp3Files.size());
#endif
if (name == "/") {
out.println(F("<ul>"));
}
@@ -550,7 +554,7 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
out.print(F("\"><b>"));
out.print(name);
out.println(F("</b></li>"));
delay(0); // Yield to allow network stack to send buffered data
yield(); // Yield to allow network stack to send buffered data
}
for (size_t i = 0; i < mp3Files.size(); i++) {
@@ -559,10 +563,12 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
out.print(F("\">"));
out.print(mp3Files[i]);
out.println(F("</li>"));
#ifdef DEBUG
Serial.printf("stream song: %s\n",mp3Files[i].c_str());
#endif
// Yield every few items to allow the async web server to send buffered data
if (i % 5 == 4) {
delay(1);
yield();
}
}
@@ -572,7 +578,7 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
if (name == "/") {
out.println(F("</ul>"));
delay(0); // Final yield before completing
yield(); // Final yield before completing
}
}