From f30826877f6c9703c4a5b9780728ed810c5643a8 Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sat, 29 Jul 2017 11:59:36 +0200 Subject: [PATCH 1/8] Fixed reverse motor direction compatibility with 3.1 --- js/msp/MSPHelper.js | 8 ++- tabs/configuration.html | 114 +++++++++++++++++++++++++++++++++++++++- tabs/configuration.js | 10 +++- 3 files changed, 126 insertions(+), 6 deletions(-) diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 83aade7dc0..f4b2161fe6 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -557,7 +557,9 @@ MspHelper.prototype.process_data = function(dataHandler) { case MSPCodes.MSP_MIXER_CONFIG: MIXER_CONFIG.mixer = data.readU8(); - MIXER_CONFIG.reverseMotorDir = data.readU8(); + if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + MIXER_CONFIG.reverseMotorDir = data.readU8(); + } break; case MSPCodes.MSP_FEATURE_CONFIG: @@ -1161,7 +1163,9 @@ MspHelper.prototype.crunch = function(code) { break; case MSPCodes.MSP_SET_MIXER_CONFIG: buffer.push8(MIXER_CONFIG.mixer) - .push8(MIXER_CONFIG.reverseMotorDir); + if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + buffer.push8(MIXER_CONFIG.reverseMotorDir); + } break; case MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG: buffer.push16(BOARD_ALIGNMENT_CONFIG.roll) diff --git a/tabs/configuration.html b/tabs/configuration.html index 258052b955..dddd765be9 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -324,7 +324,7 @@
-
+
@@ -411,7 +411,7 @@
- + @@ -528,6 +528,116 @@ + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+ + + + diff --git a/tabs/configuration.js b/tabs/configuration.js index e889677f34..03b9122e80 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -174,12 +174,17 @@ TABS.configuration.initialize = function (callback, scrollPosition) { function refreshMixerPreview() { var mixer = MIXER_CONFIG.mixer - var reverse = MIXER_CONFIG.reverseMotorDir ? "_reversed" : ""; - + var reverse = ""; + + if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + MIXER_CONFIG.reverseMotorDir ? "_reversed" : ""; + } + $('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[mixer - 1].image + reverse + '.svg'); }; var reverseMotorSwitch_e = $('#reverseMotorSwitch'); + var reverseMotor_e = $('.reverseMotor'); reverseMotorSwitch_e.change(function() { MIXER_CONFIG.reverseMotorDir = $(this).prop('checked') ? 1 : 0; @@ -208,6 +213,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { BEEPER_CONFIG.beepers.generateElements(template, destination); } else { beeper_e.hide(); + reverseMotor_e.hide(); } // translate to user-selected language From e5b777b86f480a131d3b853b95ba24d6c0c35cbc Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sat, 29 Jul 2017 12:19:25 +0200 Subject: [PATCH 2/8] Fix model preview in motors tab --- tabs/configuration.js | 2 +- tabs/motors.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tabs/configuration.js b/tabs/configuration.js index 03b9122e80..c5fd6e28b0 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -177,7 +177,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { var reverse = ""; if (semver.lt(CONFIG.apiVersion, "1.36.0")) { - MIXER_CONFIG.reverseMotorDir ? "_reversed" : ""; + reverse = MIXER_CONFIG.reverseMotorDir ? "_reversed" : ""; } $('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[mixer - 1].image + reverse + '.svg'); diff --git a/tabs/motors.js b/tabs/motors.js index d8eeba0d36..99f0f50904 100644 --- a/tabs/motors.js +++ b/tabs/motors.js @@ -167,8 +167,14 @@ TABS.motors.initialize = function (callback) { lines.attr('d', graphHelpers.line); } - function update_model(val) { - $('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[val - 1].image + '.svg'); + function update_model(mixer) { + var reverse = ""; + + if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + reverse = MIXER_CONFIG.reverseMotorDir ? "_reversed" : ""; + } + + $('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[mixer - 1].image + reverse + '.svg'); } function process_html() { From 70c69b807dcb021a59245919b0da81f6a49cff36 Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sat, 29 Jul 2017 12:24:42 +0200 Subject: [PATCH 3/8] Fix for fix --- js/msp/MSPHelper.js | 4 ++-- tabs/configuration.js | 2 +- tabs/motors.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index f4b2161fe6..5108c03a76 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -557,7 +557,7 @@ MspHelper.prototype.process_data = function(dataHandler) { case MSPCodes.MSP_MIXER_CONFIG: MIXER_CONFIG.mixer = data.readU8(); - if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { MIXER_CONFIG.reverseMotorDir = data.readU8(); } break; @@ -1163,7 +1163,7 @@ MspHelper.prototype.crunch = function(code) { break; case MSPCodes.MSP_SET_MIXER_CONFIG: buffer.push8(MIXER_CONFIG.mixer) - if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { buffer.push8(MIXER_CONFIG.reverseMotorDir); } break; diff --git a/tabs/configuration.js b/tabs/configuration.js index c5fd6e28b0..3be59e0f70 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -176,7 +176,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { var mixer = MIXER_CONFIG.mixer var reverse = ""; - if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { reverse = MIXER_CONFIG.reverseMotorDir ? "_reversed" : ""; } diff --git a/tabs/motors.js b/tabs/motors.js index 99f0f50904..e3b29530dc 100644 --- a/tabs/motors.js +++ b/tabs/motors.js @@ -170,7 +170,7 @@ TABS.motors.initialize = function (callback) { function update_model(mixer) { var reverse = ""; - if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { reverse = MIXER_CONFIG.reverseMotorDir ? "_reversed" : ""; } From ca39c713e93e460ccde33a68449bb7065fafd1fb Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sat, 29 Jul 2017 15:14:37 +0200 Subject: [PATCH 4/8] Fixed motor tab for BF 3.1.x. Fixed #568 --- tabs/motors.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tabs/motors.js b/tabs/motors.js index e3b29530dc..9de84d13a0 100644 --- a/tabs/motors.js +++ b/tabs/motors.js @@ -42,7 +42,14 @@ TABS.motors.initialize = function (callback) { $('#content').load("./tabs/motors.html", process_html); } - MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, get_arm_status); + // Get information from Betaflight + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + // BF 3.2.0+ + MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, get_arm_status); + } else { + // BF 3.1.x or older + MSP.send_message(MSPCodes.MSP_MISC, false, false, get_arm_status); + } function update_arm_status() { self.armed = bit_check(CONFIG.mode, 0); From a71d6d8a6173fcee35bd6ff1e62a9c968d55d1ec Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sat, 29 Jul 2017 15:29:10 +0200 Subject: [PATCH 5/8] Bump version number to 3.1.3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 25ce2cd585..085ba5764b 100755 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "minimum_chrome_version": "38", - "version": "3.1.2", + "version": "3.1.3", "author": "Betaflight Squad", "name": "Betaflight - Configurator", "short_name": "Betaflight", From 192b3f1341eca6b468150d3ec0f0a228e3eb71c2 Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sat, 29 Jul 2017 15:35:05 +0200 Subject: [PATCH 6/8] Added release information --- changelog.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog.html b/changelog.html index 2c92a8faf9..c09237c1e9 100755 --- a/changelog.html +++ b/changelog.html @@ -1,8 +1,8 @@ -2016.07.29 - 3.1.2 - BetaFlight +2017.07.29 - 3.1.3 - BetaFlight
    -
  • First version suitable for 3.2 features
  • +
  • Fixed incompatibility issues with BF 3.1.x
-2016.03.09 - 3.1.1 - BetaFlight +2017.07.28 - 3.1.1 - BetaFlight
  • Changed donation page to english
From 63af808444b4d24a035f0e068924410055ab237e Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sat, 29 Jul 2017 20:45:56 +0200 Subject: [PATCH 7/8] Several fixes for compatibility with BF 3.1.x --- _locales/en/messages.json | 39 ++++++++ js/fc.js | 9 ++ js/msp/MSPHelper.js | 96 +++++++++++-------- main.js | 7 ++ tabs/configuration.css | 10 +- tabs/configuration.html | 139 ++++++++++++++++++++++++++++ tabs/configuration.js | 187 +++++++++++++++++++++++++++++++++++++- 7 files changed, 446 insertions(+), 41 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 19f3063c46..0501d8a363 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2480,6 +2480,45 @@ "configurationMagHardware": { "message": "Magnetometer (if supported)" }, + // --------------------------------------------- + // Remove this when we officialy retire BF 3.1.x + "configurationBatteryVoltage": { + "message": "Battery Voltage" + }, + "configurationBatteryCurrent": { + "message": "Battery Current" + }, + "configurationBatteryMeterType": { + "message": "Battery Meter Type" + }, + "configurationBatteryMinimum": { + "message": "Minimum Cell Voltage" + }, + "configurationBatteryMaximum": { + "message": "Maximum Cell Voltage" + }, + "configurationBatteryWarning": { + "message": "Warning Cell Voltage" + }, + "configurationBatteryScale": { + "message": "Voltage Scale" + }, + "configurationCurrentMeterType": { + "message": "Current Meter Type" + }, + "configurationCurrent": { + "message": "Current Sensor" + }, + "configurationCurrentScale": { + "message": "Scale the output voltage to milliamps [1/10th mV/A]" + }, + "configurationCurrentOffset": { + "message": "Offset in millivolt steps" + }, + "configurationBatteryMultiwiiCurrent": { + "message": "Enable support for legacy Multiwii MSP current output" + }, + // --------------------------------------------- END "pidTuningProfile": { "message": "Profile" }, diff --git a/js/fc.js b/js/fc.js index 1e0b069fd7..0728c8d273 100644 --- a/js/fc.js +++ b/js/fc.js @@ -2,6 +2,7 @@ // define all the global variables that are uses to hold FC state var CONFIG; +var BF_CONFIG; // Remove when we officialy retire BF 3.1 var FEATURE_CONFIG; var BEEPER_CONFIG; var MIXER_CONFIG; @@ -79,6 +80,13 @@ var FC = { boardType: 0, }; + BF_CONFIG = { + currentscale: 0, + currentoffset: 0, + currentmetertype: 0, + batterycapacity: 0, + }; + FEATURE_CONFIG = { features: 0, }; @@ -228,6 +236,7 @@ var FC = { vbatmincellvoltage: 0, vbatmaxcellvoltage: 0, vbatwarningcellvoltage: 0, + batterymetertype: 1, // 1=ADC, 2=ESC }; MOTOR_CONFIG = { minthrottle: 0, diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 5108c03a76..caf1803d0b 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -171,6 +171,7 @@ MspHelper.prototype.process_data = function(dataHandler) { } break; case MSPCodes.MSP_CURRENT_METERS: + CURRENT_METERS = []; var currentMeterLength = 5; for (var i = 0; i < (data.byteLength / currentMeterLength); i++) { @@ -192,46 +193,63 @@ MspHelper.prototype.process_data = function(dataHandler) { break; case MSPCodes.MSP_VOLTAGE_METER_CONFIG: - VOLTAGE_METER_CONFIGS = []; - var voltage_meter_count = data.readU8(); - - for (var i = 0; i < voltage_meter_count; i++) { - var subframe_length = data.readU8(); - if (subframe_length != 5) { - for (var j = 0; j < subframe_length; j++) { - data.readU8(); + if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + MISC.vbatscale = data.readU8(); // 10-200 + MISC.vbatmincellvoltage = data.readU8() / 10; // 10-50 + MISC.vbatmaxcellvoltage = data.readU8() / 10; // 10-50 + MISC.vbatwarningcellvoltage = data.readU8() / 10; // 10-50 + if (semver.gte(CONFIG.apiVersion, "1.23.0")) { + MISC.batterymetertype = data.readU8(); + } + } else { + VOLTAGE_METER_CONFIGS = []; + var voltage_meter_count = data.readU8(); + + for (var i = 0; i < voltage_meter_count; i++) { + var subframe_length = data.readU8(); + if (subframe_length != 5) { + for (var j = 0; j < subframe_length; j++) { + data.readU8(); + } + } else { + var voltageMeterConfig = {}; + voltageMeterConfig.id = data.readU8(); + voltageMeterConfig.sensorType = data.readU8(); + voltageMeterConfig.vbatscale = data.readU8(); + voltageMeterConfig.vbatresdivval = data.readU8(); + voltageMeterConfig.vbatresdivmultiplier = data.readU8(); + + VOLTAGE_METER_CONFIGS.push(voltageMeterConfig); } - } else { - var voltageMeterConfig = {}; - voltageMeterConfig.id = data.readU8(); - voltageMeterConfig.sensorType = data.readU8(); - voltageMeterConfig.vbatscale = data.readU8(); - voltageMeterConfig.vbatresdivval = data.readU8(); - voltageMeterConfig.vbatresdivmultiplier = data.readU8(); - - VOLTAGE_METER_CONFIGS.push(voltageMeterConfig); } } break; case MSPCodes.MSP_CURRENT_METER_CONFIG: - var offset = 0; - CURRENT_METER_CONFIGS = []; - var current_meter_count = data.readU8(); - for (var i = 0; i < current_meter_count; i++) { - var currentMeterConfig = {}; - var subframe_length = data.readU8(); - - if (subframe_length != 6) { - for (var j = 0; j < subframe_length; j++) { - data.readU8(); - } - } else { - currentMeterConfig.id = data.readU8(); - currentMeterConfig.sensorType = data.readU8(); - currentMeterConfig.scale = data.readU16(); - currentMeterConfig.offset = data.readU16(); + if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + BF_CONFIG.currentscale = data.read16(); + BF_CONFIG.currentoffset = data.read16(); + BF_CONFIG.currentmetertype = data.readU8(); + BF_CONFIG.batterycapacity = data.readU16(); + } else { + var offset = 0; + CURRENT_METER_CONFIGS = []; + var current_meter_count = data.readU8(); + for (var i = 0; i < current_meter_count; i++) { + var currentMeterConfig = {}; + var subframe_length = data.readU8(); + + if (subframe_length != 6) { + for (var j = 0; j < subframe_length; j++) { + data.readU8(); + } + } else { + currentMeterConfig.id = data.readU8(); + currentMeterConfig.sensorType = data.readU8(); + currentMeterConfig.scale = data.readU16(); + currentMeterConfig.offset = data.readU16(); - CURRENT_METER_CONFIGS.push(currentMeterConfig); + CURRENT_METER_CONFIGS.push(currentMeterConfig); + } } } break; @@ -1273,11 +1291,11 @@ MspHelper.prototype.crunch = function(code) { case MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG: if (semver.lt(CONFIG.apiVersion, "1.36.0")) { buffer.push8(MISC.vbatscale) - .push8(Math.round(BATTERY_CONFIG.vbatmincellvoltage * 10)) - .push8(Math.round(BATTERY_CONFIG.vbatmaxcellvoltage * 10)) - .push8(Math.round(BATTERY_CONFIG.vbatwarningcellvoltage * 10)); + .push8(Math.round(MISC.vbatmincellvoltage * 10)) + .push8(Math.round(MISC.vbatmaxcellvoltage * 10)) + .push8(Math.round(MISC.vbatwarningcellvoltage * 10)); if (semver.gte(CONFIG.apiVersion, "1.23.0")) { - buffer.push8(BATTERY_CONFIG.voltageMeterSource); + buffer.push8(MISC.batterymetertype); } } break; @@ -1285,7 +1303,7 @@ MspHelper.prototype.crunch = function(code) { if (semver.lt(CONFIG.apiVersion, "1.36.0")) { buffer.push16(BF_CONFIG.currentscale) .push16(BF_CONFIG.currentoffset) - .push8(BATTERY_CONFIG.currentMeterSource) + .push8(BF_CONFIG.currentmetertype) .push16(BF_CONFIG.batterycapacity) } break; diff --git a/main.js b/main.js index 0fbd69475e..a291d2ebee 100644 --- a/main.js +++ b/main.js @@ -470,11 +470,18 @@ function updateTabList(features) { } else { $('#tabs ul.mode-connected li.tab_transponder').hide(); } + if (features.isEnabled('OSD')) { $('#tabs ul.mode-connected li.tab_osd').show(); } else { $('#tabs ul.mode-connected li.tab_osd').hide(); } + + if (semver.gte(CONFIG.apiVersion, "1.36.0")) { + $('#tabs ul.mode-connected li.tab_power').show(); + } else { + $('#tabs ul.mode-connected li.tab_power').hide(); + } } function zeroPad(value, width) { diff --git a/tabs/configuration.css b/tabs/configuration.css index 9ffb8cf7a7..ec0f135a6b 100644 --- a/tabs/configuration.css +++ b/tabs/configuration.css @@ -291,13 +291,21 @@ width: 150px; } -.tab-configuration .currentMeterSource { +.tab-configuration .currentmetertype { border: 1px solid silver; margin-right: 5px; float: left; width: 150px; } +.tab-configuration .vbatmonitoring { + margin-top: 5px; +} + +.tab-configuration .currentMonitoring { + margin-top: 5px; +} + .tab-configuration .rssi td:nth-child(2) { width: 30px; } diff --git a/tabs/configuration.html b/tabs/configuration.html index dddd765be9..e0baa07be6 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -668,11 +668,150 @@
+<<<<<<< HEAD +======= + + +
+ + + + + +
+
+
+
+
+
+ + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+
+
+
+ + + + + + + + + +
+
+
+
+
+>>>>>>> Several fixes for compatibility with BF 3.1.x
diff --git a/tabs/configuration.js b/tabs/configuration.js index 3be59e0f70..1847371dab 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -1,7 +1,8 @@ 'use strict'; TABS.configuration = { - DSHOT_PROTOCOL_MIN_VALUE: 5 + DSHOT_PROTOCOL_MIN_VALUE: 5, + SHOW_OLD_BATTERY_CONFIG: false }; TABS.configuration.initialize = function (callback, scrollPosition) { @@ -11,6 +12,13 @@ TABS.configuration.initialize = function (callback, scrollPosition) { GUI.active_tab = 'configuration'; } + if (semver.lt(CONFIG.apiVersion, "1.36.0")) { + //Show old battery configuration for pre-BF-3.2 + self.SHOW_OLD_BATTERY_CONFIG = true; + } else { + self.SHOW_OLD_BATTERY_CONFIG = false; + } + function load_config() { MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, load_beeper_config); } @@ -140,6 +148,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) { function load_name() { var next_callback = load_rx_config; + + if (self.SHOW_OLD_BATTERY_CONFIG) { + next_callback = load_battery; + } + if (semver.gte(CONFIG.apiVersion, "1.20.0")) { MSP.send_message(MSPCodes.MSP_NAME, false, false, next_callback); } else { @@ -147,6 +160,27 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } } + // ----------------------------------------------- + // Remove this when we officily retire BF 3.1.x + function load_battery() { + var next_callback = load_current; + if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { + MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, next_callback); + } else { + next_callback(); + } + } + + function load_current() { + var next_callback = load_rx_config; + if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { + MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, next_callback); + } else { + next_callback(); + } + } + // ----------------------------------------------- + function load_rx_config() { var next_callback = load_html; if (semver.gte(CONFIG.apiVersion, "1.31.0")) { @@ -558,6 +592,105 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('input[name="maxthrottle"]').val(MOTOR_CONFIG.maxthrottle); $('input[name="mincommand"]').val(MOTOR_CONFIG.mincommand); + // ----------------------------------------------- + // Remove this when we officily retire BF 3.1.x + // fill battery + if (self.SHOW_OLD_BATTERY_CONFIG) { + if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { + var batteryMeterTypes = [ + 'Onboard ADC', + 'ESC Sensor' + ]; + + var batteryMeterType_e = $('select.batterymetertype'); + for (i = 0; i < batteryMeterTypes.length; i++) { + batteryMeterType_e.append(''); + } + + batteryMeterType_e.change(function () { + MISC.batterymetertype = parseInt($(this).val()); + checkUpdateVbatControls(); + }); + batteryMeterType_e.val(MISC.batterymetertype).change(); + } else { + $('div.batterymetertype').hide(); + } + + $('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage); + $('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage); + $('input[name="warningcellvoltage"]').val(MISC.vbatwarningcellvoltage); + $('input[name="voltagescale"]').val(MISC.vbatscale); + + // fill current + var currentMeterTypes = [ + 'None', + 'Onboard ADC', + 'Virtual' + ]; + + if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { + currentMeterTypes.push('ESC Sensor'); + } + + var currentMeterType_e = $('select.currentmetertype'); + for (i = 0; i < currentMeterTypes.length; i++) { + currentMeterType_e.append(''); + } + + currentMeterType_e.change(function () { + BF_CONFIG.currentmetertype = parseInt($(this).val()); + checkUpdateCurrentControls(); + }); + currentMeterType_e.val(BF_CONFIG.currentmetertype).change(); + + $('input[name="currentscale"]').val(BF_CONFIG.currentscale); + $('input[name="currentoffset"]').val(BF_CONFIG.currentoffset); + $('input[name="multiwiicurrentoutput"]').prop('checked', MISC.multiwiicurrentoutput !== 0); + } else { + $('.oldBatteryConfig').hide(); + } + + function checkUpdateVbatControls() { + if (FEATURE_CONFIG.features.isEnabled('VBAT')) { + $('.vbatmonitoring').show(); + + if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { + $('select.batterymetertype').show(); + + if (MISC.batterymetertype !== 0) { + $('.vbatCalibration').hide(); + } + } else { + $('select.batterymetertype').hide(); + } + } else { + $('.vbatmonitoring').hide(); + } + } + + function checkUpdateCurrentControls() { + if (FEATURE_CONFIG.features.isEnabled('CURRENT_METER')) { + $('.currentMonitoring').show(); + + switch(BF_CONFIG.currentmetertype) { + case 0: + $('.currentCalibration').hide(); + $('.currentOutput').hide(); + + break; + case 3: + $('.currentCalibration').hide(); + } + + if (BF_CONFIG.currentmetertype !== 1 && BF_CONFIG.currentmetertype !== 2) { + $('.currentCalibration').hide(); + } + } else { + $('.currentMonitoring').hide(); + } + } + // ------------------------------------------------ + //fill 3D if (semver.lt(CONFIG.apiVersion, "1.14.0")) { $('.tab-configuration ._3d').hide(); @@ -611,6 +744,17 @@ TABS.configuration.initialize = function (callback, scrollPosition) { checkShowDisarmDelay(); break; + case 'VBAT': + if (self.SHOW_OLD_BATTERY_CONFIG) { + checkUpdateVbatControls(); + } + + break; + case 'CURRENT_METER': + if (self.SHOW_OLD_BATTERY_CONFIG) { + checkUpdateCurrentControls(); + } + case 'GPS': checkUpdateGpsControls(); break; @@ -650,6 +794,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) { checkUpdateGpsControls(); checkUpdate3dControls(); + if (self.SHOW_OLD_BATTERY_CONFIG) { + checkUpdateVbatControls(); + checkUpdateCurrentControls(); + } + $("input[id='unsyncedPWMSwitch']").change(function() { if ($(this).is(':checked')) { $('div.unsyncedpwmfreq').show(); @@ -678,6 +827,17 @@ TABS.configuration.initialize = function (callback, scrollPosition) { MOTOR_CONFIG.maxthrottle = parseInt($('input[name="maxthrottle"]').val()); MOTOR_CONFIG.mincommand = parseInt($('input[name="mincommand"]').val()); + if(self.SHOW_OLD_BATTERY_CONFIG) { + MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val()); + MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val()); + MISC.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val()); + MISC.vbatscale = parseInt($('input[name="voltagescale"]').val()); + + BF_CONFIG.currentscale = parseInt($('input[name="currentscale"]').val()); + BF_CONFIG.currentoffset = parseInt($('input[name="currentoffset"]').val()); + MISC.multiwiicurrentoutput = $('input[name="multiwiicurrentoutput"]').is(':checked') ? 1 : 0; + } + if(semver.gte(CONFIG.apiVersion, "1.14.0")) { MOTOR_3D_CONFIG.deadband3d_low = parseInt($('input[name="3ddeadbandlow"]').val()); MOTOR_3D_CONFIG.deadband3d_high = parseInt($('input[name="3ddeadbandhigh"]').val()); @@ -812,10 +972,35 @@ TABS.configuration.initialize = function (callback, scrollPosition) { function save_name() { var next_callback = save_rx_config; + if(self.SHOW_OLD_BATTERY_CONFIG) { + next_callback = save_battery; + } + CONFIG.name = $.trim($('input[name="craftName"]').val()); MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, next_callback); } + // ----------------------------------------------- + // Remove this when we officily retire BF 3.1.x + function save_battery() { + var next_callback = save_current; + if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { + MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG), false, next_callback); + } else { + next_callback(); + } + } + + function save_current() { + var next_callback = save_rx_config; + if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { + MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CURRENT_METER_CONFIG), false, next_callback); + } else { + next_callback(); + } + } + // ----------------------------------------------- + function save_rx_config() { var next_callback = save_to_eeprom; if (semver.gte(CONFIG.apiVersion, "1.20.0")) { From f95b6f1b9933bb72b78f0d27f40dd4236430b240 Mon Sep 17 00:00:00 2001 From: Bas Delfos Date: Sun, 30 Jul 2017 11:35:03 +0200 Subject: [PATCH 8/8] Rebased and changes as per comments --- _locales/en/messages.json | 3 - tabs/configuration.html | 164 ++++---------------------------------- tabs/configuration.js | 11 +-- 3 files changed, 17 insertions(+), 161 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 0501d8a363..f81e54b523 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2480,8 +2480,6 @@ "configurationMagHardware": { "message": "Magnetometer (if supported)" }, - // --------------------------------------------- - // Remove this when we officialy retire BF 3.1.x "configurationBatteryVoltage": { "message": "Battery Voltage" }, @@ -2518,7 +2516,6 @@ "configurationBatteryMultiwiiCurrent": { "message": "Enable support for legacy Multiwii MSP current output" }, - // --------------------------------------------- END "pidTuningProfile": { "message": "Profile" }, diff --git a/tabs/configuration.html b/tabs/configuration.html index e0baa07be6..dcf1f43db1 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -31,7 +31,7 @@
-
+
@@ -530,11 +530,10 @@ - + - - -
+ +
@@ -585,7 +584,15 @@
-
+
+ + + + + + +
+
@@ -633,17 +640,17 @@
+
- - + -
+
@@ -668,150 +675,11 @@
-<<<<<<< HEAD -======= -
-
-
-
- - - - -
-
-
-
-
-
- - - - - - - - - - - -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
-
-
-
-
- - - - - - - - - - - -
-
- -
-
- -
-
- -
-
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
-
-
- - - - - - - - - -
-
-
-
-
->>>>>>> Several fixes for compatibility with BF 3.1.x
diff --git a/tabs/configuration.js b/tabs/configuration.js index 1847371dab..cd5464a5e3 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -160,8 +160,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } } - // ----------------------------------------------- - // Remove this when we officily retire BF 3.1.x function load_battery() { var next_callback = load_current; if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { @@ -178,8 +176,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } else { next_callback(); } - } - // ----------------------------------------------- + } function load_rx_config() { var next_callback = load_html; @@ -592,8 +589,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('input[name="maxthrottle"]').val(MOTOR_CONFIG.maxthrottle); $('input[name="mincommand"]').val(MOTOR_CONFIG.mincommand); - // ----------------------------------------------- - // Remove this when we officily retire BF 3.1.x // fill battery if (self.SHOW_OLD_BATTERY_CONFIG) { if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { @@ -689,7 +684,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $('.currentMonitoring').hide(); } } - // ------------------------------------------------ //fill 3D if (semver.lt(CONFIG.apiVersion, "1.14.0")) { @@ -980,8 +974,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) { MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, next_callback); } - // ----------------------------------------------- - // Remove this when we officily retire BF 3.1.x function save_battery() { var next_callback = save_current; if (semver.gte(CONFIG.flightControllerVersion, "3.1.0")) { @@ -999,7 +991,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) { next_callback(); } } - // ----------------------------------------------- function save_rx_config() { var next_callback = save_to_eeprom;