read LittleFS.totalBytes only once on start

This commit is contained in:
MichaelDvP
2022-09-17 17:10:23 +02:00
parent 872effb297
commit 0d5d353e99
3 changed files with 10 additions and 2 deletions

View File

@@ -24,7 +24,7 @@ void SystemStatus::systemStatus(AsyncWebServerRequest * request) {
root["flash_chip_size"] = ESP.getFlashChipSize(); root["flash_chip_size"] = ESP.getFlashChipSize();
root["flash_chip_speed"] = ESP.getFlashChipSpeed(); root["flash_chip_speed"] = ESP.getFlashChipSpeed();
root["fs_total"] = LittleFS.totalBytes(); root["fs_total"] = emsesp::EMSESP::system_.FStotal();
root["fs_used"] = LittleFS.usedBytes(); root["fs_used"] = LittleFS.usedBytes();
root["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3); root["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);

View File

@@ -373,6 +373,7 @@ void System::start() {
if (low_clock_) { if (low_clock_) {
setCpuFrequencyMhz(160); setCpuFrequencyMhz(160);
} }
fstotal_ = LittleFS.totalBytes(); // read only once, it takes 500 ms to read
#endif #endif
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
@@ -784,7 +785,7 @@ void System::show_system(uuid::console::Shell & shell) {
shell.printfln(F(" SDK version: %s"), ESP.getSdkVersion()); shell.printfln(F(" SDK version: %s"), ESP.getSdkVersion());
shell.printfln(F(" CPU frequency: %lu MHz"), ESP.getCpuFreqMHz()); shell.printfln(F(" CPU frequency: %lu MHz"), ESP.getCpuFreqMHz());
shell.printfln(F(" Free heap: %lu bytes"), (uint32_t)ESP.getFreeHeap()); shell.printfln(F(" Free heap: %lu bytes"), (uint32_t)ESP.getFreeHeap());
shell.printfln(F(" FS used/total: %lu/%lu (bytes)"), LittleFS.usedBytes(), LittleFS.totalBytes()); shell.printfln(F(" FS used/total: %lu/%lu (bytes)"), LittleFS.usedBytes(), FStotal());
shell.println(); shell.println();
shell.println("Network:"); shell.println("Network:");

View File

@@ -220,6 +220,10 @@ class System {
void wifi_reconnect(); void wifi_reconnect();
void show_users(uuid::console::Shell & shell); void show_users(uuid::console::Shell & shell);
uint32_t FStotal() {
return fstotal_;
}
private: private:
static uuid::log::Logger logger_; static uuid::log::Logger logger_;
static bool restart_requested_; static bool restart_requested_;
@@ -293,6 +297,9 @@ class System {
int8_t eth_power_; int8_t eth_power_;
uint8_t eth_phy_addr_; uint8_t eth_phy_addr_;
uint8_t eth_clock_mode_; uint8_t eth_clock_mode_;
uint32_t fstotal_;
}; };
} // namespace emsesp } // namespace emsesp