Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor and use JSONencoder in WebServer.cpp #800

Open
wants to merge 2 commits into
base: Devt
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Grbl_Esp32/src/WebUI/JSONEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,20 @@ namespace WebUI {
member("S", max);
member("M", min);
}

void JSONencoder::filesystemStats(uint64_t total, uint64_t used) {
member("total", total ? ESPResponseStream::formatBytes(total) : "-1");
member("used", ESPResponseStream::formatBytes(used + 1));
int occupied_percent;
if (total) {
occupied_percent = (used * 100) / total;
//minimum if even one byte is used is 1%
if (occupied_percent <= 1) {
occupied_percent = 1;
}
} else {
occupied_percent = -1;
}
member("occupation", occupied_percent);
}
}
2 changes: 2 additions & 0 deletions Grbl_Esp32/src/WebUI/JSONEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,7 @@ namespace WebUI {
void begin_webui(const char* p, const char* help, const char* type, const char* val);
void begin_webui(const char* p, const char* help, const char* type, const int val);
void begin_webui(const char* p, const char* help, const char* type, const char* val, int min, int max);

void filesystemStats(uint64_t total, uint64_t used);
};
}
Loading