Free SDCard heap space

This commit is contained in:
George Alexandre Silva 2024-05-05 19:03:34 -03:00
parent 6a936da474
commit 8d3349d080
3 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -55,6 +55,7 @@ public:
bool loadConfigFile(TSettings* Settings);
bool cardAvailable();
bool cardBusy();
void terminate();
private:
bool initSDcard();
bool cardInitialized_;

View File

@ -109,6 +109,9 @@ void init_WifiManager()
}
};
// Free the memory from SDCard class
SDCrd.terminate();
// Reset settings (only for development)
//wm.resetSettings();