mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-03 03:13:25 +02:00
fix SD card > 4GB size display use uint64_t instead of uint32_t
allow float for space calaculation in formatBytes, limited to 2 decimals but for byte which has 0 decimal
This commit is contained in:
@@ -47,16 +47,16 @@ void ESPResponseStream::println(const char *data){
|
||||
}
|
||||
|
||||
//helper to format size to readable string
|
||||
String ESPResponseStream::formatBytes (uint32_t bytes)
|
||||
String ESPResponseStream::formatBytes (uint64_t bytes)
|
||||
{
|
||||
if (bytes < 1024) {
|
||||
return String (bytes) + " B";
|
||||
if (bytes < 1024) {
|
||||
return String ((uint16_t)bytes) + " B";
|
||||
} else if (bytes < (1024 * 1024) ) {
|
||||
return String (bytes / 1024.0) + " KB";
|
||||
return String ((float)(bytes / 1024.0),2) + " KB";
|
||||
} else if (bytes < (1024 * 1024 * 1024) ) {
|
||||
return String (bytes / 1024.0 / 1024.0) + " MB";
|
||||
return String ((float)(bytes / 1024.0 / 1024.0),2) + " MB";
|
||||
} else {
|
||||
return String (bytes / 1024.0 / 1024.0 / 1024.0) + " GB";
|
||||
return String ((float)(bytes / 1024.0 / 1024.0 / 1024.0),2) + " GB";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class ESPResponseStream{
|
||||
void print(const char *data);
|
||||
void println(const char *data);
|
||||
void flush();
|
||||
static String formatBytes (uint32_t bytes);
|
||||
static String formatBytes (uint64_t bytes);
|
||||
uint8_t client() {return _client;}
|
||||
#if defined (ENABLE_HTTP) && defined(ENABLE_WIFI)
|
||||
ESPResponseStream(WebServer * webserver);
|
||||
|
@@ -1228,8 +1228,8 @@ void Web_Server::handle_direct_SDFileList()
|
||||
_upload_status = UPLOAD_STATUS_NONE;
|
||||
}
|
||||
bool list_files = true;
|
||||
uint32_t totalspace = 0;
|
||||
uint32_t usedspace = 0;
|
||||
uint64_t totalspace = 0;
|
||||
uint64_t usedspace = 0;
|
||||
if (get_sd_state(true) != SDCARD_IDLE) {
|
||||
_webserver->sendHeader("Cache-Control","no-cache");
|
||||
_webserver->send(200, "application/json", "{\"status\":\"No SD Card\"}");
|
||||
|
Reference in New Issue
Block a user