diff --git a/data/set.device.json.gz b/data/set.device.json.gz index 0d278d22..cf2a1077 100644 Binary files a/data/set.device.json.gz and b/data/set.device.json.gz differ diff --git a/data_ungzip/set.device.json b/data_ungzip/set.device.json index ee17e69b..a6d32d35 100644 --- a/data_ungzip/set.device.json +++ b/data_ungzip/set.device.json @@ -49,6 +49,14 @@ "type": "h4", "title": "{{signal}}" }, + { + "type": "h4", + "title": "Осталось памяти: {{freeBytes}}" + }, + { + "type": "h4", + "title": "Осталось памяти: {{freePer}} %" + }, { "type": "hr" }, diff --git a/data_ungzip/set.device.json.gz b/data_ungzip/set.device.json.gz new file mode 100644 index 00000000..cf2a1077 Binary files /dev/null and b/data_ungzip/set.device.json.gz differ diff --git a/include/FileSystem.h b/include/FileSystem.h index 09fe0307..813569f7 100644 --- a/include/FileSystem.h +++ b/include/FileSystem.h @@ -10,27 +10,15 @@ #include extern FS LittleFS; using littlefs_impl::LittleFSConfig; -extern FS *filesystem; +extern FS* filesystem; #define FileFS LittleFS #define FS_NAME "LittleFS" #else -extern FS *filesystem; +extern FS* filesystem; #define FileFS SPIFFS #define FS_NAME "SPIFFS" #endif -/* -* Информация о ФС - size_t totalBytes; // всего - size_t usedBytes; // использовано - size_t maxOpenFiles; // лимит на открые файлы - size_t maxPathLength; // лимит на полное пути + имя файла - FSInfo buf; - getInfo(buf); - size_t freeBytes = buf.totalBytes - buf.usedBytes; - float freePer = buf.usedBytes / buf.totalBytes * 100; -*/ -bool getInfo(FSInfo& info) { - return FileFS.info(info); -} \ No newline at end of file +extern void getFSInfo(); +extern bool getInfo(FSInfo& info); \ No newline at end of file diff --git a/src/FileSystem.cpp b/src/FileSystem.cpp new file mode 100644 index 00000000..9a658f70 --- /dev/null +++ b/src/FileSystem.cpp @@ -0,0 +1,22 @@ +#include "FileSystem.h" +#include "Global.h" + +void getFSInfo() { + // Информация о ФС + size_t totalBytes; // всего + size_t usedBytes; // использовано + size_t maxOpenFiles; // лимит на открые файлы + size_t maxPathLength; // лимит на полное пути + имя файла + + FSInfo buf; + getInfo(buf); + size_t freeBytes = buf.totalBytes - buf.usedBytes; + float freePer = buf.usedBytes / buf.totalBytes * 100; + + jsonWriteInt(configSetupJson, F("freeBytes"), freeBytes); + jsonWriteFloat(configSetupJson, F("freePer"), freePer); +} + +bool getInfo(FSInfo& info) { + return FileFS.info(info); +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 78e16b92..3bd8fb0a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,7 @@ #include "items/vSensorUltrasonic.h" #include "Telegram.h" #include "SoftUART.h" +#include "FileSystem.h" void not_async_actions(); @@ -66,9 +67,8 @@ void setup() { #ifdef SSDP_ENABLED SsdpInit(); #endif - + getFSInfo(); //esp_log_level_set("esp_littlefs", ESP_LOG_NONE); - just_load = false; initialized = true; }