Mount SD card on startup

This commit is contained in:
Correl Roush 2023-04-11 18:43:22 -04:00
parent 0eac844638
commit d991d7c563

View file

@ -1,4 +1,5 @@
#include <Arduino.h> #include <Arduino.h>
#include <SD.h>
#include <M5Unified.h> #include <M5Unified.h>
#include <WiFi.h> #include <WiFi.h>
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
@ -733,8 +734,10 @@ protected:
} }
}; };
App* app; App* app;
App::Choices current_app; App::Choices current_app;
bool sd_ok = false;
void setup(void) { void setup(void) {
auto cfg = M5.config(); auto cfg = M5.config();
@ -746,6 +749,18 @@ void setup(void) {
M5.Display.init(); M5.Display.init();
M5.Display.setTextSize(3); M5.Display.setTextSize(3);
M5.Display.setCursor(0, M5.Display.height() / 4); 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..."); M5.Display.println("Starting up...");
app = new System; app = new System;