diff --git a/src/main.cpp b/src/main.cpp index 0490053..824a0a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ void setup() diagnosticPrintln("Configuration OK!"); displayWifiCreds(); - displaySelectedFile(); + displayStatus(); // Setup is done, light up the LED Serial.println("All setup & ready to go!"); diff --git a/src/utils.cpp b/src/utils.cpp index 4488e12..9006480 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -75,13 +75,25 @@ void displayWifiCreds() display.display(); } -void displaySelectedFile() +void displayStatus() { + clearMessageArea(); + + String volume = String(preferences.getUChar(CURRENT_VOLUME)); + display.println("Volume: " + volume); + String prefix = "Son: "; - displayText(prefix + preferences.getString(SELECTED_FILE, "").substring(0, LINE_LENGTH - prefix.length())); + display.println(prefix + preferences.getString(SELECTED_FILE, "").substring(0, LINE_LENGTH - prefix.length())); + + display.println("\nRetourne moi !"); + + display.display(); } -void displayVolume() { - String volume = String(preferences.getUChar(CURRENT_VOLUME)); - displayText("Volume: " + volume); -} \ No newline at end of file +void selectFile(String fileName) +{ + preferences.putString(SELECTED_FILE, fileName); + displayStatus(); + Serial.print("Select new file: "); + Serial.println(fileName); +} diff --git a/src/utils.h b/src/utils.h index 29d4abf..a622399 100644 --- a/src/utils.h +++ b/src/utils.h @@ -11,8 +11,10 @@ void clearMessageArea(); void displayText(String text); void play(); +void selectFile(String fileName); + void displayWifiCreds(); -void displaySelectedFile(); +void displayStatus(); void diagnosticPrint(String text); void diagnosticPrintln(String text); diff --git a/src/webHandlers.cpp b/src/webHandlers.cpp index ac4147d..0682e14 100644 --- a/src/webHandlers.cpp +++ b/src/webHandlers.cpp @@ -87,15 +87,12 @@ void onListFiles(AsyncWebServerRequest *request) void onSelectFile(AsyncWebServerRequest *request) { - Serial.print("Select file: "); + Serial.println("Select file"); if (request->hasParam("fileName", true)) { String selectedFile = request->getParam("fileName", true)->value(); - preferences.putString(SELECTED_FILE, selectedFile); - Serial.print(selectedFile); - displaySelectedFile(); + selectFile(selectedFile); } - Serial.println(); onStatus(request); } @@ -152,6 +149,7 @@ void onUploadFile(AsyncWebServerRequest *request, String filename, size_t index, Serial.printf("Upload end: %s, %u B\n", filename.c_str(), index + len); request->_tempFile.close(); request->redirect("/"); + selectFile(filename); } }