mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-12-26 16:01:49 +01:00
Display whole status on screen + select file after uploading
This commit is contained in:
parent
4bee1156b1
commit
a0aacd4b22
4 changed files with 25 additions and 13 deletions
|
@ -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!");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
void selectFile(String fileName)
|
||||
{
|
||||
preferences.putString(SELECTED_FILE, fileName);
|
||||
displayStatus();
|
||||
Serial.print("Select new file: ");
|
||||
Serial.println(fileName);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue