cleanups, memory savings
This commit is contained in:
@@ -470,6 +470,11 @@ void DirectoryNode::buildFlatMP3List(std::vector<std::pair<DirectoryNode *, int>
|
||||
}
|
||||
}
|
||||
|
||||
const size_t DirectoryNode::getNumOfFiles()
|
||||
{
|
||||
return subdirectories.size();
|
||||
}
|
||||
|
||||
DirectoryNode *DirectoryNode::advanceToNextMP3(const String *currentGlobal)
|
||||
{
|
||||
bool useFirst = false;
|
||||
@@ -537,7 +542,6 @@ DirectoryNode *DirectoryNode::advanceToNextMP3(const String *currentGlobal)
|
||||
void DirectoryNode::streamDirectoryHTML(Print &out) const {
|
||||
if (name == "/") {
|
||||
out.println(F("<ul>"));
|
||||
delay(0); // yield to WiFi/other tasks
|
||||
}
|
||||
|
||||
if (name != "/") {
|
||||
@@ -546,29 +550,24 @@ void DirectoryNode::streamDirectoryHTML(Print &out) const {
|
||||
out.print(F("\"><b>"));
|
||||
out.print(name);
|
||||
out.println(F("</b></li>"));
|
||||
delay(0); // yield periodically while streaming
|
||||
}
|
||||
|
||||
delay(0);
|
||||
|
||||
for (size_t i = 0; i < mp3Files.size(); i++) {
|
||||
out.print(F("<li data-id=\""));
|
||||
out.print(ids[i]);
|
||||
out.print(F("\">"));
|
||||
out.print(mp3Files[i]);
|
||||
out.println(F("</li>"));
|
||||
if ((i & 0x0F) == 0) { // yield every ~16 items
|
||||
delay(0);
|
||||
}
|
||||
}
|
||||
|
||||
for (DirectoryNode* child : subdirectories) {
|
||||
delay(0); // yield before descending
|
||||
child->streamDirectoryHTML(out);
|
||||
delay(0); // and after returning
|
||||
}
|
||||
|
||||
if (name == "/") {
|
||||
out.println(F("</ul>"));
|
||||
delay(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user