mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-29 17:19:50 +02:00
Display sd space in [ESP210]
Fix occupation always to 1%
This commit is contained in:
@@ -875,7 +875,12 @@ bool COMMANDS::execute_internal_command (int cmd, String cmd_params, level_authe
|
||||
int8_t state = get_sd_state(true);
|
||||
if (state == SDCARD_IDLE) {
|
||||
listDir(SD, "/", 10, espresponse->client());
|
||||
String ssd = "[SD Free:" + ESPResponseStream::formatBytes(SD.totalBytes() - SD.usedBytes());
|
||||
ssd +=" Used:" + ESPResponseStream::formatBytes(SD.usedBytes());
|
||||
ssd +=" Total:" + ESPResponseStream::formatBytes(SD.totalBytes());
|
||||
ssd +="]";
|
||||
espresponse->println ("");
|
||||
espresponse->println (ssd.c_str());
|
||||
}
|
||||
else espresponse->println ((state == SDCARD_NOT_PRESENT) ? "No SD card" : "Busy");
|
||||
}
|
||||
|
@@ -1366,19 +1366,20 @@ void Web_Server::handle_direct_SDFileList()
|
||||
}
|
||||
jsonfile+="],\"path\":\"";
|
||||
jsonfile+=path + "\",";
|
||||
static uint32_t volTotal = 1;
|
||||
static uint32_t volFree = 0;
|
||||
jsonfile+="\"total\":\"";
|
||||
String stotalspace,susedspace;
|
||||
//SDCard are in GB or MB but no less
|
||||
totalspace = SD.totalBytes();
|
||||
usedspace = SD.usedBytes();
|
||||
stotalspace = ESPResponseStream::formatBytes(totalspace);
|
||||
susedspace = ESPResponseStream::formatBytes(usedspace);
|
||||
susedspace = ESPResponseStream::formatBytes(usedspace+1);
|
||||
|
||||
uint32_t occupedspace = (volFree/volTotal)*100;
|
||||
uint32_t occupedspace = 1;
|
||||
uint32_t usedspace2 = usedspace/(1024*1024);
|
||||
uint32_t totalspace2 = totalspace/(1024*1024);
|
||||
occupedspace = (usedspace2 * 100)/totalspace2;
|
||||
//minimum if even one byte is used is 1%
|
||||
if ( (occupedspace <= 1) && (volTotal!=volFree)) {
|
||||
if ( occupedspace <= 1) {
|
||||
occupedspace=1;
|
||||
}
|
||||
if (totalspace) {
|
||||
|
Reference in New Issue
Block a user