From eab725ea599d632a2b4d3e90a723dea3af702303 Mon Sep 17 00:00:00 2001 From: mikeller Date: Mon, 27 Mar 2017 01:22:39 +1300 Subject: [PATCH 1/2] Removed 'BLACKBOX' and 'SDCARD' features. --- _locales/en/messages.json | 12 +++++++++++ js/Features.js | 11 +++++++--- main.js | 6 ------ tabs/onboard_logging.js | 43 +++++++++++++++++++-------------------- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 907c90d7..0250280e 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1380,6 +1380,18 @@ "blackboxButtonSave": { "message": "Save and reboot" }, + "blackboxLoggingNone": { + "message": "No Logging" + }, + "blackboxLoggingFlash": { + "message": "Onboard Flash" + }, + "blackboxLoggingSdCard": { + "message": "SD Card" + }, + "blackboxLoggingSerial": { + "message": "Serial Port" + }, "serialLoggingSupportedNote": { "message": "You can log to an external logging device (such as an OpenLog or compatible clone) by using a serial port. Configure the port on the Ports tab." diff --git a/js/Features.js b/js/Features.js index f7aae595..cbe598cb 100644 --- a/js/Features.js +++ b/js/Features.js @@ -20,10 +20,15 @@ var Features = function (config) { {bit: 14, group: 'rxMode', mode: 'select', name: 'RX_MSP'}, {bit: 15, group: 'rssi', name: 'RSSI_ADC'}, {bit: 16, group: 'other', name: 'LED_STRIP'}, - {bit: 17, group: 'other', name: 'DISPLAY', haveTip: true}, - {bit: 19, group: 'other', name: 'BLACKBOX', haveTip: true} + {bit: 17, group: 'other', name: 'DISPLAY', haveTip: true} ]; + if (!semver.gte(config.apiVersion, "1.33.0")) { + features.push( + {bit: 19, group: 'other', name: 'BLACKBOX', haveTip: true} + ); + } + if (semver.gte(config.apiVersion, "1.12.0")) { features.push( {bit: 20, group: 'other', name: 'CHANNEL_FORWARDING'} @@ -58,7 +63,7 @@ var Features = function (config) { features.push( {bit: 23, group: 'pidTuning', name: 'SUPEREXPO_RATES'} ); - } else { + } else if (!semver.gte(config.apiVersion, "1.33.0")) { features.push( {bit: 23, group: 'other', name: 'SDCARD'} ); diff --git a/main.js b/main.js index 82244cca..d69325ed 100644 --- a/main.js +++ b/main.js @@ -458,12 +458,6 @@ function updateTabList(features) { $('#tabs ul.mode-connected li.tab_logging').hide(); } - if (features.isEnabled('BLACKBOX')) { - $('#tabs ul.mode-connected li.tab_onboard_logging').show(); - } else { - $('#tabs ul.mode-connected li.tab_onboard_logging').hide(); - } - if (features.isEnabled('TRANSPONDER')) { $('#tabs ul.mode-connected li.tab_transponder').show(); } else { diff --git a/tabs/onboard_logging.js b/tabs/onboard_logging.js index 1aa8a991..410721d0 100644 --- a/tabs/onboard_logging.js +++ b/tabs/onboard_logging.js @@ -16,7 +16,7 @@ TABS.onboard_logging.initialize = function (callback) { self = this, saveCancelled, eraseCancelled; - if (GUI.active_tab != 'onboard_logging') { + if (GUI.active_tab !== 'onboard_logging') { GUI.active_tab = 'onboard_logging'; } @@ -58,7 +58,7 @@ TABS.onboard_logging.initialize = function (callback) { } function gcd(a, b) { - if (b == 0) + if (b === 0) return a; return gcd(b, a % b); @@ -125,9 +125,9 @@ TABS.onboard_logging.initialize = function (callback) { .toggleClass("sdcard-supported", SDCARD.supported) .toggleClass("blackbox-config-supported", BLACKBOX.supported) - .toggleClass("blackbox-supported", blackboxSupport == 'yes') - .toggleClass("blackbox-maybe-supported", blackboxSupport == 'maybe') - .toggleClass("blackbox-unsupported", blackboxSupport == 'no'); + .toggleClass("blackbox-supported", blackboxSupport === 'yes') + .toggleClass("blackbox-maybe-supported", blackboxSupport === 'maybe') + .toggleClass("blackbox-unsupported", blackboxSupport === 'no'); if (dataflashPresent) { // UI hooks @@ -163,17 +163,17 @@ TABS.onboard_logging.initialize = function (callback) { } function populateDevices() { - var - deviceSelect = $(".blackboxDevice select").empty(); + var deviceSelect = $(".blackboxDevice select").empty(); - deviceSelect.append(''); + deviceSelect.append(''); if (DATAFLASH.ready) { - deviceSelect.append(''); + deviceSelect.append(''); } if (SDCARD.supported) { - deviceSelect.append(''); + deviceSelect.append(''); } - + deviceSelect.append(''); + deviceSelect.val(BLACKBOX.blackboxDevice); } @@ -191,17 +191,16 @@ TABS.onboard_logging.initialize = function (callback) { {num: 1, denom: 7}, {num: 1, denom: 8}, {num: 1, denom: 16}, - {num: 1, denom: 32}, + {num: 1, denom: 32} ], loggingRatesSelect = $(".blackboxRate select"); - - var addedCurrentValue = false; + var pidRate = 8000 / PID_ADVANCED_CONFIG.gyro_sync_denom / PID_ADVANCED_CONFIG.pid_process_denom; for (var i = 0; i < loggingRates.length; i++) { var loggingRate = Math.round(pidRate / loggingRates[i].denom); var loggingRateUnit = " Hz"; - if (loggingRate != Infinity) { - if (gcd(loggingRate, 1000)==1000) { + if (loggingRate !== Infinity) { + if (gcd(loggingRate, 1000) === 1000) { loggingRate /= 1000; loggingRateUnit = " KHz"; } @@ -260,12 +259,12 @@ TABS.onboard_logging.initialize = function (callback) { update_bar_width($(".tab-onboard_logging .sdcard-other"), SDCARD.totalSizeKB - SDCARD.freeSizeKB, SDCARD.totalSizeKB, "Unavailable space", true); update_bar_width($(".tab-onboard_logging .sdcard-free"), SDCARD.freeSizeKB, SDCARD.totalSizeKB, "Free space for logs", true); - $(".btn a.erase-flash, .btn a.save-flash").toggleClass("disabled", DATAFLASH.usedSize == 0); + $(".btn a.erase-flash, .btn a.save-flash").toggleClass("disabled", DATAFLASH.usedSize === 0); $(".tab-onboard_logging") - .toggleClass("sdcard-error", SDCARD.state == MSP.SDCARD_STATE_FATAL) - .toggleClass("sdcard-initializing", SDCARD.state == MSP.SDCARD_STATE_CARD_INIT || SDCARD.state == MSP.SDCARD_STATE_FS_INIT) - .toggleClass("sdcard-ready", SDCARD.state == MSP.SDCARD_STATE_READY); + .toggleClass("sdcard-error", SDCARD.state === MSP.SDCARD_STATE_FATAL) + .toggleClass("sdcard-initializing", SDCARD.state === MSP.SDCARD_STATE_CARD_INIT || SDCARD.state === MSP.SDCARD_STATE_FS_INIT) + .toggleClass("sdcard-ready", SDCARD.state === MSP.SDCARD_STATE_READY); switch (SDCARD.state) { case MSP.SDCARD_STATE_NOT_PRESENT: @@ -358,7 +357,7 @@ TABS.onboard_logging.initialize = function (callback) { show_saving_dialog(); function onChunkRead(chunkAddress, chunkDataView) { - if (chunkDataView != null) { + if (chunkDataView !== null) { // Did we receive any data? if (chunkDataView.byteLength > 0) { nextAddress += chunkDataView.byteLength; @@ -411,7 +410,7 @@ TABS.onboard_logging.initialize = function (callback) { if (error) { console.error(error.message); - if (error.message != "User cancelled") { + if (error.message !== "User cancelled") { GUI.log(chrome.i18n.getMessage('dataflashFileWriteFailed')); } return; From 5753602657ef376155a8d5793baee9060ca37998 Mon Sep 17 00:00:00 2001 From: mikeller Date: Tue, 28 Mar 2017 01:14:19 +1300 Subject: [PATCH 2/2] Hide logging rate selection when logging is disabled. --- tabs/onboard_logging.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tabs/onboard_logging.js b/tabs/onboard_logging.js index 410721d0..2c0aa43a 100644 --- a/tabs/onboard_logging.js +++ b/tabs/onboard_logging.js @@ -140,21 +140,32 @@ TABS.onboard_logging.initialize = function (callback) { $('.tab-onboard_logging a.save-flash-cancel').click(flash_save_cancel); $('.tab-onboard_logging a.save-flash-dismiss').click(dismiss_saving_dialog); } - + + var deviceSelect = $(".blackboxDevice select"); + var loggingRatesSelect = $(".blackboxRate select"); + if (BLACKBOX.supported) { $(".tab-onboard_logging a.save-settings").click(function() { - var rate = $(".blackboxRate select").val().split('/'); + var rate = loggingRatesSelect.val().split('/'); BLACKBOX.blackboxRateNum = parseInt(rate[0], 10); BLACKBOX.blackboxRateDenom = parseInt(rate[1], 10); - BLACKBOX.blackboxDevice = parseInt($(".blackboxDevice select").val(), 10); + BLACKBOX.blackboxDevice = parseInt(deviceSelect.val(), 10); MSP.send_message(MSPCodes.MSP_SET_BLACKBOX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BLACKBOX_CONFIG), false, save_to_eeprom); }); } - populateLoggingRates(); - populateDevices(); + populateLoggingRates(loggingRatesSelect); + populateDevices(deviceSelect); + + deviceSelect.change(function() { + if ($(this).val() === "0") { + $("div.blackboxRate").hide(); + } else { + $("div.blackboxRate").show(); + } + }).change(); update_html(); @@ -162,8 +173,8 @@ TABS.onboard_logging.initialize = function (callback) { }); } - function populateDevices() { - var deviceSelect = $(".blackboxDevice select").empty(); + function populateDevices(deviceSelect) { + deviceSelect.empty(); deviceSelect.append(''); if (DATAFLASH.ready) { @@ -177,7 +188,7 @@ TABS.onboard_logging.initialize = function (callback) { deviceSelect.val(BLACKBOX.blackboxDevice); } - function populateLoggingRates() { + function populateLoggingRates(loggingRatesSelect) { // Offer a reasonable choice of logging rates (if people want weird steps they can use CLI) var @@ -192,8 +203,7 @@ TABS.onboard_logging.initialize = function (callback) { {num: 1, denom: 8}, {num: 1, denom: 16}, {num: 1, denom: 32} - ], - loggingRatesSelect = $(".blackboxRate select"); + ]; var pidRate = 8000 / PID_ADVANCED_CONFIG.gyro_sync_denom / PID_ADVANCED_CONFIG.pid_process_denom; for (var i = 0; i < loggingRates.length; i++) {