Display whole status on screen + select file after uploading

This commit is contained in:
Gabriel Augendre 2023-01-06 15:39:53 +01:00
parent 4bee1156b1
commit a0aacd4b22
4 changed files with 25 additions and 13 deletions

View file

@ -34,7 +34,7 @@ void setup()
diagnosticPrintln("Configuration OK!"); diagnosticPrintln("Configuration OK!");
displayWifiCreds(); displayWifiCreds();
displaySelectedFile(); displayStatus();
// Setup is done, light up the LED // Setup is done, light up the LED
Serial.println("All setup & ready to go!"); Serial.println("All setup & ready to go!");

View file

@ -75,13 +75,25 @@ void displayWifiCreds()
display.display(); display.display();
} }
void displaySelectedFile() void displayStatus()
{ {
clearMessageArea();
String volume = String(preferences.getUChar(CURRENT_VOLUME));
display.println("Volume: " + volume);
String prefix = "Son: "; 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() { void selectFile(String fileName)
String volume = String(preferences.getUChar(CURRENT_VOLUME)); {
displayText("Volume: " + volume); preferences.putString(SELECTED_FILE, fileName);
} displayStatus();
Serial.print("Select new file: ");
Serial.println(fileName);
}

View file

@ -11,8 +11,10 @@ void clearMessageArea();
void displayText(String text); void displayText(String text);
void play(); void play();
void selectFile(String fileName);
void displayWifiCreds(); void displayWifiCreds();
void displaySelectedFile(); void displayStatus();
void diagnosticPrint(String text); void diagnosticPrint(String text);
void diagnosticPrintln(String text); void diagnosticPrintln(String text);

View file

@ -87,15 +87,12 @@ void onListFiles(AsyncWebServerRequest *request)
void onSelectFile(AsyncWebServerRequest *request) void onSelectFile(AsyncWebServerRequest *request)
{ {
Serial.print("Select file: "); Serial.println("Select file");
if (request->hasParam("fileName", true)) if (request->hasParam("fileName", true))
{ {
String selectedFile = request->getParam("fileName", true)->value(); String selectedFile = request->getParam("fileName", true)->value();
preferences.putString(SELECTED_FILE, selectedFile); selectFile(selectedFile);
Serial.print(selectedFile);
displaySelectedFile();
} }
Serial.println();
onStatus(request); 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); Serial.printf("Upload end: %s, %u B\n", filename.c_str(), index + len);
request->_tempFile.close(); request->_tempFile.close();
request->redirect("/"); request->redirect("/");
selectFile(filename);
} }
} }