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_; 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. /// @brief Transfer settings from config file on a SD card to the device.
/// @param nvMemory* where to save /// @param nvMemory* where to save
/// @param TSettings* passing a struct is required, to save memory /// @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::initSDcard() { return false; }
bool SDCard::cardAvailable() { return false; } bool SDCard::cardAvailable() { return false; }
bool SDCard::cardBusy() { return false; } bool SDCard::cardBusy() { return false; }
void SDCard::terminate() {};
#endif //BUILD_SDMMC #endif //BUILD_SDMMC

View File

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

View File

@ -108,7 +108,10 @@ void init_WifiManager()
forceConfig = true; forceConfig = true;
} }
}; };
// Free the memory from SDCard class
SDCrd.terminate();
// Reset settings (only for development) // Reset settings (only for development)
//wm.resetSettings(); //wm.resetSettings();