diff --git a/src/main.cpp b/src/main.cpp index 1715a99..5a53854 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,7 @@ // define pins for RFID #define CS_RFID 32 // SIC, tried 4 and 32 but only this worked! #define RST_RFID 33 +// this does not work as the irq pin is input only: #define IRQ_RFID 34 // Audio DAC @@ -471,6 +472,11 @@ String getState() else jsonState["title"] = "Angehalten"; // Store in flash + if (currentNode != nullptr) + jsonState["filepath"] = currentNode->getCurrentPlayingFilePath(); + else + jsonState["filepath"] = ""; + jsonState["time"] = audio.getAudioCurrentTime(); jsonState["volume"] = audio.getVolume(); jsonState["length"] = audio.getAudioFileDuration(); @@ -717,8 +723,8 @@ void setup() pinMode(BTN_NEXT, INPUT_PULLUP); pinMode(BTN_PREV, INPUT_PULLUP); - /* setup the IRQ pin*/ - pinMode(IRQ_RFID, INPUT_PULLUP); + /* setup the IRQ pin, not working because the pin is input only:*/ + //pinMode(IRQ_RFID, INPUT_PULLUP); pinMode(CS_RFID, OUTPUT); pinMode(CS_SDCARD, OUTPUT); @@ -792,7 +798,7 @@ void setup() AsyncWiFiManager wifiManager(&server, &dns); // Memory optimizations for WiFiManager - wifiManager.setDebugOutput(false); // Disable debug strings + wifiManager.setDebugOutput(true); // Disable debug strings wifiManager.setMinimumSignalQuality(20); // Reduce AP scan results wifiManager.setRemoveDuplicateAPs(true); // Remove duplicate APs from memory diff --git a/web/index.html b/web/index.html index ca3c825..3ad48dc 100644 --- a/web/index.html +++ b/web/index.html @@ -40,7 +40,15 @@ %DIRECTORY%

-
+ + + + +
-

Edit RFID Mapping

+

Edit RFID Mapping


@@ -61,6 +69,19 @@
+

Move / Rename File

+ + + + + + +

Delete File

+ + + + + - \ No newline at end of file + diff --git a/web/script.js b/web/script.js index 51fd815..52e45ad 100644 --- a/web/script.js +++ b/web/script.js @@ -84,6 +84,16 @@ function displayState(state) { document.getElementById("voltage").innerHTML = state['voltage']+' mV'; document.getElementById("heap").innerHTML = state['heap']+' bytes free heap'; document.getElementById("uid").innerHTML = 'Last NFC ID: '+state['uid']; + + /* ==== Autofill convenience fields ==== */ + if (state['filepath']) { + document.getElementById('moveFrom').value = state['filepath']; + document.getElementById('deleteFile').value = state['filepath']; + document.getElementById('song').value = state['filepath']; + } + if (state['uid']) { + document.getElementById('rfid').value = state['uid']; + } var elements = document.getElementsByClassName('play-button'); var btn = elements[0]; @@ -260,3 +270,60 @@ function resetUploadForm() { // Clear file input document.getElementById('uploadFile').value = ''; } + +/* ================= File Manager Functions ================= */ + +function toggleFileManager() { + var fm = document.getElementById('fileManager'); + if (fm.style.display === 'none' || fm.style.display === '') { + fm.style.display = 'block'; + } else { + fm.style.display = 'none'; + } +} + +function moveFile() { + var from = document.getElementById('moveFrom').value.trim(); + var to = document.getElementById('moveTo').value.trim(); + if (!from || !to) { + alert('Please provide both source and destination paths.'); + return; + } + var xhr = new XMLHttpRequest(); + xhr.open('GET', '/move_file?from=' + encodeURIComponent(from) + '&to=' + encodeURIComponent(to), true); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status >= 200 && xhr.status < 300) { + alert('File moved successfully.'); + location.reload(); + } else { + alert('Move failed: ' + (xhr.responseText || 'Unknown error')); + } + } + }; + xhr.send(); +} + +function deleteFile() { + var filename = document.getElementById('deleteFile').value.trim(); + if (!filename) { + alert('Please provide filename to delete.'); + return; + } + if (!confirm('Are you sure you want to delete ' + filename + '?')) { + return; + } + var xhr = new XMLHttpRequest(); + xhr.open('GET', '/delete_file?filename=' + encodeURIComponent(filename), true); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status >= 200 && xhr.status < 300) { + alert('File deleted successfully.'); + location.reload(); + } else { + alert('Delete failed: ' + (xhr.responseText || 'Unknown error')); + } + } + }; + xhr.send(); +}