Display loading messages on screen

This commit is contained in:
Gabriel Augendre 2023-01-02 16:42:33 +01:00
parent 14f4b14948
commit 0a6a042daf
2 changed files with 36 additions and 16 deletions

13
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,13 @@
{
"files.associations": {
"array": "cpp",
"deque": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"vector": "cpp",
"string_view": "cpp",
"initializer_list": "cpp",
"regex": "cpp"
}
}

View file

@ -24,8 +24,8 @@
#define OLED_RESET -1 #define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C #define SCREEN_ADDRESS 0x3C
#define LOGO_HEIGHT 16 #define LOGO_HEIGHT 16
#define LOGO_WIDTH 16 #define LOGO_WIDTH 16
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
@ -91,12 +91,27 @@ void setup()
pinMode(LED, OUTPUT); pinMode(LED, OUTPUT);
digitalWrite(LED, LOW); digitalWrite(LED, LOW);
// Screen
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
{
Serial.println(F("SSD1306 allocation failed"));
return;
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println("Chargement...");
display.display();
pinMode(BUTTON, INPUT_PULLUP); pinMode(BUTTON, INPUT_PULLUP);
// Setup SPIFFS // Setup SPIFFS
if (!SPIFFS.begin()) if (!SPIFFS.begin())
{ {
Serial.println("SPIFFS error. Exiting."); Serial.println("SPIFFS error. Exiting.");
display.println("Impossible d'acceder aux fichiers...");
display.display();
return; return;
} }
@ -109,6 +124,8 @@ void setup()
{ {
selectedFile = fileName; selectedFile = fileName;
Serial.println("Selected " + fileName); Serial.println("Selected " + fileName);
display.println("Selectionne : " + fileName);
display.display();
break; break;
} }
file.close(); file.close();
@ -135,6 +152,8 @@ void setup()
#endif #endif
String wifiMessage = wifiMode + " IP: " + wifiIP; String wifiMessage = wifiMode + " IP: " + wifiIP;
Serial.println(wifiMessage); Serial.println(wifiMessage);
display.println(wifiMessage);
display.display();
// Server // Server
server.on("/play", HTTP_GET, onPlay); server.on("/play", HTTP_GET, onPlay);
@ -146,25 +165,13 @@ void setup()
server.begin(); server.begin();
Serial.println("Server ready!"); Serial.println("Server ready!");
display.println("Serveur pret !");
display.display();
// Audio // Audio
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // Max 21 audio.setVolume(21); // Max 21
// Screen
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
return;
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);
display.println(wifiMessage);
display.display();
// Setup is done, light up the LED // Setup is done, light up the LED
digitalWrite(LED, HIGH); digitalWrite(LED, HIGH);
} }