Skip to content

Commit

Permalink
Added UI display for SD Size and Remaining Size in MB
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMueller2003 committed Oct 26, 2021
1 parent 0816248 commit 109d6f6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ESPixelStick/src/FileMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,17 @@ void c_FileMgr::GetListOfSdFiles (String & Response)
break;
}

#ifdef ARDUINO_ARCH_ESP32
ResponseJsonDoc[F ("totalBytes")] = SDFS.totalBytes ();
ResponseJsonDoc[F ("usedBytes")] = SDFS.usedBytes ();

#else
FSInfo fs_info;
SDFS.info (fs_info);
ResponseJsonDoc[F ("totalBytes")] = fs_info.totalBytes;
ResponseJsonDoc[F ("usedBytes")] = fs_info.usedBytes;
ResponseJsonDoc[F ("blockSize")] = fs_info.blockSize;
ResponseJsonDoc[F ("pageSize")] = fs_info.pageSize;
ResponseJsonDoc[F ("maxOpenFiles")] = fs_info.maxOpenFiles;
ResponseJsonDoc[F ("maxPathLength")] = fs_info.maxPathLength;
ResponseJsonDoc[F ("totalBytes")] = fs_info.totalBytes;
ResponseJsonDoc[F ("usedBytes")] = fs_info.usedBytes;

#endif
File dir = SDFS.open ("/", CN_r);

while (true)
Expand Down
14 changes: 14 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,20 @@
<a id="FileDeleteButton" class="button">Remove Selected File(s)</a>
<!-- <a id="FileUploadButton" class="button">Upload Selected File(s)</a> -->
</div>
<div>
<div>
<label class="control-label col-sm-2" for="totalBytes">SD Size (MB):</label>
<output class="form-control" id="totalBytes" type="number"></output>
</div>
<div>
<label class="control-label col-sm-2" for="usedBytes">Used SD Size (MB):</label>
<output class="form-control" id="usedBytes" type="number"></output>
</div>
<div>
<label class="control-label col-sm-2" for="remainingBytes">Remaining SD Size (MB):</label>
<output class="form-control" id="remainingBytes" type="number"></output>
</div>
</div>
<div>
<fieldset>
<legend class="esps-legend">Files</legend>
Expand Down
10 changes: 10 additions & 0 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ function RequestListOfFiles()

} // RequestListOfFiles

function BytesToMB(Value)
{
return (Value / (1024 * 1024)).toFixed();

} // BytesToMB

function ProcessGetFileListResponse(JsonConfigData)
{
// console.info("ProcessGetFileListResponse");
Expand All @@ -389,6 +395,10 @@ function ProcessGetFileListResponse(JsonConfigData)
$("#li-filemanagement").addClass("hidden");
}

$("#totalBytes").val(BytesToMB (JsonConfigData.totalBytes));
$("#usedBytes").val(BytesToMB (JsonConfigData.usedBytes));
$("#remainingBytes").val(BytesToMB (JsonConfigData.totalBytes - JsonConfigData.usedBytes) );

Fseq_File_List = JsonConfigData;

clearTimeout(FseqFileListRequestTimer);
Expand Down

0 comments on commit 109d6f6

Please sign in to comment.