From d991d7c56331e2739d794bf4a3dff50570e8463b Mon Sep 17 00:00:00 2001 From: Correl Date: Tue, 11 Apr 2023 18:43:22 -0400 Subject: [PATCH] Mount SD card on startup --- src/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ea3c8a1..c6e0ecb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -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;