Don't read all dirs at startup.

This commit is contained in:
Fabian Schlenz 2022-08-21 15:26:29 +02:00
parent 4840c150c2
commit 45dfe0cfe0
3 changed files with 7 additions and 5 deletions

View File

@ -13,7 +13,6 @@ class PlaylistManager {
public:
PlaylistManager();
std::vector<String> dirs;
std::map<String, String> map;
Playlist get_playlist(String rfid_id);
bool has_playlist(String rfid_id);

View File

@ -22,6 +22,7 @@ MFRC522* rfid;
void setup() {
pinMode(PIN_CS_SD, OUTPUT); digitalWrite(PIN_CS_SD, HIGH);
pinMode(PIN_CS_RFID, OUTPUT); digitalWrite(PIN_CS_RFID, HIGH);
Serial.begin(115200);
WiFi.begin("Schlenz", "1410WischlingenPanda");
log_i("Connecting to WiFi...");
@ -41,7 +42,7 @@ void setup() {
Serial.print("Connected to WiFi. IP address: ");
Serial.println(WiFi.localIP());
ArduinoOTA.begin();
Serial.println("Waiting for OTA...");
log_i("Waiting for OTA...");
for(int i=0; i<20; i++) {
ArduinoOTA.handle();
delay(100);

View File

@ -6,6 +6,7 @@ PlaylistManager::PlaylistManager() {
SPIMaster::enable_sd();
current_rfid_tag_id = String("");
/*
File root = SD.open("/");
while(File entry = root.openNextFile()) {
if (entry.isDirectory()) {
@ -17,6 +18,8 @@ PlaylistManager::PlaylistManager() {
}
}
}
root.close();
*/
if (!SD.exists("/_mapping.txt")) {
Serial.println("WARNING: /_mapping.txt not found!");
@ -37,7 +40,7 @@ PlaylistManager::PlaylistManager() {
Serial.printf(" Adding mapping: %s=>%s\n", rfid_id.c_str(), folder.c_str());
map[rfid_id] = folder;
if (folder.charAt(0)=='/') {
/*if (folder.charAt(0)=='/') {
bool found=false;
for (String f: dirs) {
if (f.equals(folder)) {
@ -48,12 +51,11 @@ PlaylistManager::PlaylistManager() {
if (!found) {
Serial.printf("WARNING: Found mapping for RFID id %s which maps to non-existing folder %s!\n", rfid_id.c_str(), folder.c_str());
}
}
}*/
}
}
f.close();
}
root.close();
}
Playlist PlaylistManager::get_playlist(String rfid_id) {