mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-11-21 23:48:07 +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 buttonLastState = HIGH;
|
||||||
byte currentVolume = 12;
|
byte currentVolume = 12;
|
||||||
|
|
||||||
bool fileIsValid(String fileName) {
|
bool fileIsValid(String fileName)
|
||||||
|
{
|
||||||
return !fileName.startsWith(".") && (fileName.endsWith(".mp3") || fileName.endsWith(".aac") || fileName.endsWith(".wav"));
|
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.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);
|
display.setCursor(SCREEN_MSG_X, SCREEN_MSG_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayText(String text) {
|
void displayText(String text)
|
||||||
|
{
|
||||||
clearMessageArea();
|
clearMessageArea();
|
||||||
display.println(text);
|
display.println(text);
|
||||||
display.display();
|
display.display();
|
||||||
|
@ -168,8 +171,8 @@ void setup()
|
||||||
// Screen
|
// Screen
|
||||||
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
|
if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS))
|
||||||
{
|
{
|
||||||
Serial.println(F("SSD1306 allocation failed"));
|
Serial.println("Display init failed");
|
||||||
return;
|
while (true);
|
||||||
}
|
}
|
||||||
display.clearDisplay();
|
display.clearDisplay();
|
||||||
display.setTextSize(1);
|
display.setTextSize(1);
|
||||||
|
@ -187,7 +190,7 @@ void setup()
|
||||||
Serial.println("SPIFFS error. Exiting.");
|
Serial.println("SPIFFS error. Exiting.");
|
||||||
display.println("Impossible d'acceder aux fichiers...");
|
display.println("Impossible d'acceder aux fichiers...");
|
||||||
display.display();
|
display.display();
|
||||||
return;
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pinMode(SD_CS, OUTPUT);
|
pinMode(SD_CS, OUTPUT);
|
||||||
|
@ -199,7 +202,7 @@ void setup()
|
||||||
Serial.println("Error talking to SD card!");
|
Serial.println("Error talking to SD card!");
|
||||||
display.println("Impossible d'acceder a la carte SD...");
|
display.println("Impossible d'acceder a la carte SD...");
|
||||||
display.display();
|
display.display();
|
||||||
return;
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedFile = preferences.getString("selectedFile", "");
|
selectedFile = preferences.getString("selectedFile", "");
|
||||||
|
|
Loading…
Reference in a new issue