From 6157c875f9ccb5609ede5ba74387d0671d3dfdb7 Mon Sep 17 00:00:00 2001 From: NightHawk32 Date: Tue, 24 Nov 2015 18:01:56 -0500 Subject: [PATCH 1/2] Renamed global dataflash components, fixed detection for global dataflash display. --- js/serial_backend.js | 74 +++++++++++++++++++++++--------------------- main.css | 25 ++++++++------- main.html | 11 +++---- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/js/serial_backend.js b/js/serial_backend.js index 704c114c..df901468 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -250,21 +250,12 @@ function onConnect() { $('div#connectbutton a.connect_state').text(chrome.i18n.getMessage('disconnect')).addClass('active'); $('div#connectbutton a.connect').addClass('active'); $('#tabs ul.mode-disconnected').hide(); - $('#tabs ul.mode-connected').show(); - - var sensor_state = $('#sensor-status'); - sensor_state.show(); - - var port_picker = $('#portsinput'); - port_picker.hide(); - - var dataflash = $('#dataflash_wrapper'); - dataflash.show(); + $('#tabs ul.mode-connected').show(); MSP.send_message(MSP_codes.MSP_STATUS, false, false); // TEST code for dataflash status in header - MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false); + //MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, update_html()); function formatFilesize(bytes) { if (bytes < 1024) { @@ -281,34 +272,45 @@ function onConnect() { return megabytes.toFixed(1) + "MB"; } - function update_html() { - if (DATAFLASH.usedSize > 0) { - $(".dataflash-used").css({ - width: (DATAFLASH.usedSize / DATAFLASH.totalSize * 100) + "%", - display: 'block' - }); - - $(".dataflash-used div").text('Dataflash: used ' + formatFilesize(DATAFLASH.usedSize)); - } else { - $(".dataflash-used").css({ - display: 'none' - }); - } + function update_dataflash_global() { + var supportsDataflash = DATAFLASH.totalSize > 0; + if (supportsDataflash){ - if (DATAFLASH.totalSize - DATAFLASH.usedSize > 0) { - $(".dataflash-free").css({ - width: ((DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%", - display: 'block' - }); - $(".dataflash-free div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize)); + $(".noflash_global").css({ + display: 'none' + }); + + $(".dataflash-contents_global").css({ + display: 'block' + }); + + $(".dataflash-free_global").css({ + width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%", + display: 'block' + }); + $(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize)); } else { - $(".dataflash-free").css({ - display: 'none' - }); - } + $(".noflash_global").css({ + display: 'block' + }); + + $(".dataflash-contents_global").css({ + display: 'none' + }); + } } - update_html(); + + MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, update_dataflash_global); + + var sensor_state = $('#sensor-status'); + sensor_state.show(); + + var port_picker = $('#portsinput'); + port_picker.hide(); + + var dataflash = $('#dataflash_wrapper_global'); + dataflash.show(); @@ -335,7 +337,7 @@ function onClosed(result) { var port_picker = $('#portsinput'); port_picker.show(); - var dataflash = $('#dataflash_wrapper'); + var dataflash = $('#dataflash_wrapper_global'); dataflash.hide(); } diff --git a/main.css b/main.css index 681a0f78..9303d4b4 100644 --- a/main.css +++ b/main.css @@ -1347,7 +1347,7 @@ dialog { } /* Dataflash element styling*/ -#dataflash_wrapper { +#dataflash_wrapper_global { color:white; font-size:10px; margin-top: 20px; @@ -1376,7 +1376,7 @@ dialog { line-height: 12px; } -.dataflash-contents { +.dataflash-contents_global { margin-top: 18px; border: 1px solid #4A4A4A; background-color: #4A4A4A; @@ -1390,11 +1390,17 @@ dialog { } -.dataflash-contents .notsupported { +.dataflash-free_global { + background-color: #59AA29; + border-radius: 4px; +} + + +.dataflash-contents_global .notsupported_global { display: none; } -.dataflash-contents li { +.dataflash-contents_global li { height: 5px; position: relative; box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.20); @@ -1402,7 +1408,7 @@ dialog { } -.dataflash-contents li div { +.dataflash-contents_global li div { position: absolute; top: -18px; margin-top: 0px; @@ -1414,12 +1420,7 @@ dialog { color:silver; } -.dataflash-used { - background-color: #59AA29; - border-radius: 2px; -} - -.dataflash-contents progress::-webkit-progress-bar { +.dataflash-contents_global progress::-webkit-progress-bar { height: 8px; background-color: #eee; } @@ -1428,7 +1429,7 @@ dialog { background-color: #bcf; } -.noflash { +.noflash_gloabal { display:none; color: #4f4f4f; text-align: center; diff --git a/main.html b/main.html index 0bbf6792..9f042554 100755 --- a/main.html +++ b/main.html @@ -126,13 +126,10 @@
-
-
No dataflash
chip found
-
    -
  • -
    Dataflash: used space
    -
  • -
  • +
    +
    No dataflash
    chip found
    +
      +
    • Dataflash: free space
    From d21b4a157fee8f80dd3750d150fc6e0c6ebe3419 Mon Sep 17 00:00:00 2001 From: NightHawk32 Date: Tue, 24 Nov 2015 18:17:53 -0500 Subject: [PATCH 2/2] Typo in css classes, update global dataflash display on every dataflash summary respond. --- js/msp.js | 1 + js/serial_backend.js | 117 ++++++++++++++++++++++++++----------------- main.css | 2 +- 3 files changed, 74 insertions(+), 46 deletions(-) diff --git a/js/msp.js b/js/msp.js index 6d5e81f3..50d1bf60 100644 --- a/js/msp.js +++ b/js/msp.js @@ -823,6 +823,7 @@ var MSP = { DATAFLASH.totalSize = 0; DATAFLASH.usedSize = 0; } + update_dataflash_global(); break; case MSP_codes.MSP_DATAFLASH_READ: // No-op, let callback handle it diff --git a/js/serial_backend.js b/js/serial_backend.js index df901468..f67aa9cf 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -256,52 +256,9 @@ function onConnect() { // TEST code for dataflash status in header //MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, update_html()); - - function formatFilesize(bytes) { - if (bytes < 1024) { - return bytes + "B"; - } - var kilobytes = bytes / 1024; - - if (kilobytes < 1024) { - return Math.round(kilobytes) + "kB"; - } - - var megabytes = kilobytes / 1024; - - return megabytes.toFixed(1) + "MB"; - } - function update_dataflash_global() { - var supportsDataflash = DATAFLASH.totalSize > 0; - if (supportsDataflash){ - - $(".noflash_global").css({ - display: 'none' - }); - - $(".dataflash-contents_global").css({ - display: 'block' - }); - - $(".dataflash-free_global").css({ - width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%", - display: 'block' - }); - $(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize)); - } else { - $(".noflash_global").css({ - display: 'block' - }); - - $(".dataflash-contents_global").css({ - display: 'none' - }); - } - - } - MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, update_dataflash_global); + MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false); var sensor_state = $('#sensor-status'); sensor_state.show(); @@ -439,7 +396,34 @@ function highByte(num) { function lowByte(num) { return 0x00FF & num; -} +}function update_dataflash_global() { + var supportsDataflash = DATAFLASH.totalSize > 0; + if (supportsDataflash){ + + $(".noflash_global").css({ + display: 'none' + }); + + $(".dataflash-contents_global").css({ + display: 'block' + }); + + $(".dataflash-free_global").css({ + width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%", + display: 'block' + }); + $(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize)); + } else { + $(".noflash_global").css({ + display: 'block' + }); + + $(".dataflash-contents_global").css({ + display: 'none' + }); + } + + } function specificByte(num, pos) { return 0x000000FF & (num >> (8 * pos)); @@ -457,3 +441,46 @@ function bit_clear(num, bit) { return num & ~(1 << bit); } +function update_dataflash_global() { + function formatFilesize(bytes) { + if (bytes < 1024) { + return bytes + "B"; + } + var kilobytes = bytes / 1024; + + if (kilobytes < 1024) { + return Math.round(kilobytes) + "kB"; + } + + var megabytes = kilobytes / 1024; + + return megabytes.toFixed(1) + "MB"; + } + + var supportsDataflash = DATAFLASH.totalSize > 0; + if (supportsDataflash){ + + $(".noflash_global").css({ + display: 'none' + }); + + $(".dataflash-contents_global").css({ + display: 'block' + }); + + $(".dataflash-free_global").css({ + width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%", + display: 'block' + }); + $(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize)); + } else { + $(".noflash_global").css({ + display: 'block' + }); + + $(".dataflash-contents_global").css({ + display: 'none' + }); + } + + } diff --git a/main.css b/main.css index 9303d4b4..39847fb3 100644 --- a/main.css +++ b/main.css @@ -1429,7 +1429,7 @@ dialog { background-color: #bcf; } -.noflash_gloabal { +.noflash_global { display:none; color: #4f4f4f; text-align: center;