[ai] refactorings
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user