diff --git a/src/drivers/storage/SDCard.cpp b/src/drivers/storage/SDCard.cpp index e21b7a0..1cc773f 100644 --- a/src/drivers/storage/SDCard.cpp +++ b/src/drivers/storage/SDCard.cpp @@ -57,6 +57,15 @@ bool SDCard::cardBusy() return cardBusy_; } +/// @brief End the card to free heap space. +void SDCard::terminate() +{ + iSD_->end(); +#ifdef BUILD_SDSPI + ispi_->end(); +#endif +} + /// @brief Transfer settings from config file on a SD card to the device. /// @param nvMemory* where to save /// @param TSettings* passing a struct is required, to save memory @@ -203,5 +212,6 @@ bool SDCard::loadConfigFile(TSettings* Settings) { return false; } bool SDCard::initSDcard() { return false; } bool SDCard::cardAvailable() { return false; } bool SDCard::cardBusy() { return false; } +void SDCard::terminate() {}; #endif //BUILD_SDMMC diff --git a/src/drivers/storage/SDCard.h b/src/drivers/storage/SDCard.h index 768fc07..65b5b50 100644 --- a/src/drivers/storage/SDCard.h +++ b/src/drivers/storage/SDCard.h @@ -55,6 +55,7 @@ public: bool loadConfigFile(TSettings* Settings); bool cardAvailable(); bool cardBusy(); + void terminate(); private: bool initSDcard(); bool cardInitialized_; diff --git a/src/wManager.cpp b/src/wManager.cpp index fa336af..3ff86f0 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -108,7 +108,10 @@ void init_WifiManager() forceConfig = true; } }; - + + // Free the memory from SDCard class + SDCrd.terminate(); + // Reset settings (only for development) //wm.resetSettings();