mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-11-21 15:38:06 +01:00
Reformat file and add inifinte loops instead of returning setup
This commit is contained in:
parent
aed9942c02
commit
028d136ac4
1 changed files with 12 additions and 9 deletions
17
src/main.cpp
17
src/main.cpp
|
@ -56,16 +56,19 @@ Preferences preferences;
|
|||
byte buttonLastState = HIGH;
|
||||
byte currentVolume = 12;
|
||||
|
||||
bool fileIsValid(String fileName) {
|
||||
bool fileIsValid(String fileName)
|
||||
{
|
||||
return !fileName.startsWith(".") && (fileName.endsWith(".mp3") || fileName.endsWith(".aac") || fileName.endsWith(".wav"));
|
||||
}
|
||||
|
||||
void clearMessageArea() {
|
||||
void clearMessageArea()
|
||||
{
|
||||
display.fillRect(SCREEN_MSG_X, SCREEN_MSG_Y, SCREEN_WIDTH - SCREEN_MSG_X, SCREEN_HEIGHT - SCREEN_MSG_Y, BLACK);
|
||||
display.setCursor(SCREEN_MSG_X, SCREEN_MSG_Y);
|
||||
}
|
||||
|
||||
void displayText(String text) {
|
||||
void displayText(String text)
|
||||
{
|
||||
clearMessageArea();
|
||||
display.println(text);
|
||||
display.display();
|
||||
|
@ -168,8 +171,8 @@ void setup()
|
|||
// Screen
|
||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
|
||||
{
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
return;
|
||||
Serial.println("Display init failed");
|
||||
while (true);
|
||||
}
|
||||
display.clearDisplay();
|
||||
display.setTextSize(1);
|
||||
|
@ -187,7 +190,7 @@ void setup()
|
|||
Serial.println("SPIFFS error. Exiting.");
|
||||
display.println("Impossible d'acceder aux fichiers...");
|
||||
display.display();
|
||||
return;
|
||||
while (true);
|
||||
}
|
||||
|
||||
pinMode(SD_CS, OUTPUT);
|
||||
|
@ -199,7 +202,7 @@ void setup()
|
|||
Serial.println("Error talking to SD card!");
|
||||
display.println("Impossible d'acceder a la carte SD...");
|
||||
display.display();
|
||||
return;
|
||||
while (true);
|
||||
}
|
||||
|
||||
selectedFile = preferences.getString("selectedFile", "");
|
||||
|
|
Loading…
Reference in a new issue