simple visual progress bar (#7)

* download files directly to sd instead of a buffer

- this fixes running out of memory while downloading large files

* simple visual download progressbar
This commit is contained in:
Stefan Schnitzler
2019-11-17 02:30:30 +01:00
committed by VoltZ
parent 3e626f1046
commit 99e09bd17c
4 changed files with 789 additions and 727 deletions
+19
View File
@@ -0,0 +1,19 @@
#include <string>
#include "utils/formatting.hpp"
// adapted from GM9i's byte parsing.
std::string formatBytes(int bytes) {
char out[32];
if(bytes == 1)
snprintf(out, sizeof(out), "%d Byte", bytes);
else if(bytes < 1024)
snprintf(out, sizeof(out), "%d Bytes", bytes);
else if(bytes < 1024 * 1024)
snprintf(out, sizeof(out), "%.1f KB", (float)bytes / 1024);
else if (bytes < 1024 * 1024 * 1024)
snprintf(out, sizeof(out), "%.1f MB", (float)bytes / 1024 / 1024);
else
snprintf(out, sizeof(out), "%.1f GB", (float)bytes / 1024 / 1024 / 1024);
return out;
}