Mount SD card on startup
This commit is contained in:
parent
0eac844638
commit
d991d7c563
1 changed files with 15 additions and 0 deletions
15
src/main.cpp
15
src/main.cpp
|
@ -1,4 +1,5 @@
|
|||
#include <Arduino.h>
|
||||
#include <SD.h>
|
||||
#include <M5Unified.h>
|
||||
#include <WiFi.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
@ -733,8 +734,10 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
App* app;
|
||||
App::Choices current_app;
|
||||
bool sd_ok = false;
|
||||
|
||||
void setup(void) {
|
||||
auto cfg = M5.config();
|
||||
|
@ -746,6 +749,18 @@ void setup(void) {
|
|||
M5.Display.init();
|
||||
M5.Display.setTextSize(3);
|
||||
M5.Display.setCursor(0, M5.Display.height() / 4);
|
||||
M5.Display.print("Mounting SD.");
|
||||
sd_ok = SD.begin(GPIO_NUM_4, SPI, 25000000);
|
||||
int sd_tries = 1;
|
||||
while (!sd_ok) {
|
||||
sd_tries++;
|
||||
if (sd_tries > 5) break;
|
||||
delay(500);
|
||||
M5.Display.print(".");
|
||||
sd_ok = SD.begin(GPIO_NUM_4, SPI, 25000000);
|
||||
}
|
||||
M5.Display.println(sd_ok ? "ok." : "failed.");
|
||||
delay(500);
|
||||
M5.Display.println("Starting up...");
|
||||
|
||||
app = new System;
|
||||
|
|
Loading…
Reference in a new issue