diff --git a/src/components/data-flash/DataFlash.vue b/src/components/data-flash/DataFlash.vue index cc5ee76148..38d8a74540 100644 --- a/src/components/data-flash/DataFlash.vue +++ b/src/components/data-flash/DataFlash.vue @@ -46,10 +46,14 @@ export default { } const kilobytes = bytes / 1024; if (kilobytes < 1024) { - return `${Math.round(kilobytes)}kB`; + return `${Math.round(kilobytes)}KB`; } const megabytes = kilobytes / 1024; - return `${megabytes.toFixed(1)}MB`; + if (megabytes < 1024) { + return `${megabytes.toFixed(1)}MB`; + } + const gigabytes = megabytes / 1024; + return `${gigabytes.toFixed(1)}GB`; }, indicatorWidth() { if (!this.supportDataflash) return; diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index 73c98d4be3..9e604e7250 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -1361,6 +1361,7 @@ MspHelper.prototype.process_data = function(dataHandler) { FC.SDCARD.filesystemLastError = data.readU8(); FC.SDCARD.freeSizeKB = data.readU32(); FC.SDCARD.totalSizeKB = data.readU32(); + update_dataflash_global(); break; case MSPCodes.MSP_BLACKBOX_CONFIG: FC.BLACKBOX.supported = (data.readU8() & 1) != 0; diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 5db7ba518e..3f2032ab29 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -635,6 +635,7 @@ function onConnect() { MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false); MSP.send_message(MSPCodes.MSP_BATTERY_CONFIG, false, false); MSP.send_message(MSPCodes.MSP_DATAFLASH_SUMMARY, false, false); + MSP.send_message(MSPCodes.MSP_SDCARD_SUMMARY, false, false); if (FC.CONFIG.boardType === 0 || FC.CONFIG.boardType === 2) { startLiveDataRefreshTimer(); diff --git a/src/js/update_dataflash_global.js b/src/js/update_dataflash_global.js index 588c6b029b..6cd13af726 100644 --- a/src/js/update_dataflash_global.js +++ b/src/js/update_dataflash_global.js @@ -13,13 +13,17 @@ export function update_dataflash_global() { } const megabytes = kilobytes / 1024; - - return `${megabytes.toFixed(1)}MB`; + if (megabytes < 1024) { + return `${megabytes.toFixed(1)}MB`; + } + const gigabytes = megabytes / 1024; + return `${gigabytes.toFixed(1)}GB`; } - const supportsDataflash = FC.DATAFLASH.totalSize > 0; + const supportsDataflash = FC.DATAFLASH.supported && FC.DATAFLASH.totalSize > 0; + const supportsDatacard = FC.SDCARD.supported && FC.SDCARD.totalSizeKB > 0; - if (supportsDataflash){ + if (supportsDataflash || supportsDatacard) { $(".noflash_global").css({ display: 'none', }); @@ -28,8 +32,19 @@ export function update_dataflash_global() { display: 'block', }); - $(".dataflash-progress_global").val(`${100-(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize) / FC.DATAFLASH.totalSize * 100}`); - $(".dataflash-contents_global div").text(`Dataflash: free ${formatFilesize(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize)}`); + let dataflashProgress; + let dataflashProgressText; + + if (supportsDataflash) { + dataflashProgress = 100 - (FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize) / FC.DATAFLASH.totalSize * 100; + dataflashProgressText = `Dataflash: free ${formatFilesize(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize)}`; + } + if (supportsDatacard) { + dataflashProgress = 100 - FC.SDCARD.freeSizeKB / FC.SDCARD.totalSizeKB * 100; + dataflashProgressText = `SD Card: free ${formatFilesize(FC.SDCARD.freeSizeKB * 1024)}`; + } + $(".dataflash-progress_global").val(dataflashProgress); + $(".dataflash-contents_global div").text(dataflashProgressText); } else { $(".noflash_global").css({ display: 'block',