diff --git a/Grbl_Esp32/commands.cpp b/Grbl_Esp32/commands.cpp index f1298477..e1e69964 100644 --- a/Grbl_Esp32/commands.cpp +++ b/Grbl_Esp32/commands.cpp @@ -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"); } diff --git a/Grbl_Esp32/web_server.cpp b/Grbl_Esp32/web_server.cpp index 1e09d9b3..a4d4933a 100644 --- a/Grbl_Esp32/web_server.cpp +++ b/Grbl_Esp32/web_server.cpp @@ -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) {