Use SDCard usage where available

When an SD Card is available it is the more interesing
metric in terms of space usage. We are therefore using
it here.

Signed-off-by: Mimoja <git@mimoja.de>
This commit is contained in:
Mimoja
2023-06-19 16:42:36 +02:00
committed by Mimoja
parent f487092f7f
commit 9c83d8b5a5
3 changed files with 9 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ class DynStorage {
DynStorage();
void begin();
void listFiles();
size_t freeSpace();
private:
bool isInited;

View File

@@ -44,8 +44,13 @@ static void initSDCard() {
}
#endif
void copyToSD(FS &sourceFS, const char* source_path){
File root = sourceFS.open(source_path);
size_t DynStorage::freeSpace(){
this->begin();
#ifdef HAS_SDCARD
return SD.totalBytes() - SD.usedBytes();
#endif
return LittleFS.totalBytes() - LittleFS.usedBytes();
}
void copyFile(File in, File out) {
Serial.print("Copying ");

View File

@@ -136,7 +136,7 @@ void wsSendSysteminfo() {
sys["heap"] = ESP.getFreeHeap();
sys["recordcount"] = tagDB.size();
sys["dbsize"] = tagDB.size() * sizeof(tagRecord);
sys["littlefsfree"] = LittleFS.totalBytes() - LittleFS.usedBytes();
sys["littlefsfree"] = Storage.freeSpace();
sys["apstate"] = apInfo.state;
sys["runstate"] = config.runStatus;