From b61d20323d917a8838efdfe1d62156a6a5775a1c Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Fri, 6 Oct 2017 07:03:18 -0700 Subject: [PATCH 01/12] This functions, but does not look great, and needs some debris cleaned up before merging. This could ship in an emergency but I will try to do better first. --- _locales/en/messages.json | 15 ++++++++ js/fc.js | 18 ++++++++- js/msp/MSPHelper.js | 61 ++++++++++++++++++++++++++++++ tabs/failsafe.html | 78 +++++++++++++++++++++++++++++++++++++++ tabs/failsafe.js | 12 ++++++ 5 files changed, 183 insertions(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d0cb9187..514ba2fe 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1721,6 +1721,21 @@ "failsafeKillSwitchHelp": { "message": "Set this option to make the failsafe switch, configured in the modes tab, act as a direct kill switch, bypassing the selected failsafe procedure. Note: Arming is blocked with the failsafe kill switch in the ON position" }, + + + + + + "failsafeMinDistanceItem": { + "message": "Failsafe Minimum Distance" + }, + "failsafeMinDistanceProcedureItem": { + "message": "Failsafe Minimum Distance Procedure" + }, + + + + "mainHelpArmed": { "message": "Motor Arming" }, diff --git a/js/fc.js b/js/fc.js index 4805823a..a4ea24d7 100644 --- a/js/fc.js +++ b/js/fc.js @@ -376,7 +376,15 @@ var FC = { failsafe_throttle: 0, failsafe_kill_switch: 0, failsafe_throttle_low_delay: 0, - failsafe_procedure: 0 + failsafe_procedure: 0, + failsafe_recovery_delay: 0, + + failsafe_fw_roll_angle: 0, + failsafe_fw_pitch_angle: 0, + failsafe_fw_yaw_rate: 0, + failsafe_stick_motion_threshold: 0, + failsafe_min_distance: 0, + failsafe_min_distance_procedure: 0 }; FW_CONFIG = { @@ -464,6 +472,14 @@ var FC = { ); } + // Unsure which version these will actually deploy in, guidance welcome. Using 1.7.3 + // so it works for the moment. And I'm really not sure how it works anyhow + if (semver.gte(CONFIG.flightControllerVersion, '1.7.3')) { + features.push( + {bit: 30, group: 'rxFailsafeExtended', name: 'FAILSAFE_EXTENDED', haveTip: false, showNameInTip: false} + ); + } + return features.reverse(); }, isFeatureEnabled: function (featureName, features) { diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 1b0dcced..7865c57e 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -617,8 +617,25 @@ var mspHelper = (function (gui) { offset += 2; FAILSAFE_CONFIG.failsafe_procedure = data.getUint8(offset); offset++; + FAILSAFE_CONFIG.failsafe_recovery_delay = data.getUint8(offset); + offset++; + + FAILSAFE_CONFIG.failsafe_fw_roll_angle = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_fw_pitch_angle = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_fw_yaw_rate = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_stick_motion_threshold = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_min_distance = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_min_distance_procedure = data.getUint8(offset); + offset++; + break; + case MSPCodes.MSP_RXFAIL_CONFIG: //noinspection JSUndeclaredVariable RXFAIL_CONFIG = []; // empty the array as new data is coming in @@ -1194,6 +1211,50 @@ var mspHelper = (function (gui) { buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay)); buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay)); buffer.push(FAILSAFE_CONFIG.failsafe_procedure); + buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay); + + // API version check needed here? + //if (semver.gte(CONFIG.apiVersion, "1.21.0")) { + + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_min_distance)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_min_distance)); + + buffer.push(FAILSAFE_CONFIG.failsafe_min_distance_procedure); + //} +/* + + FAILSAFE_CONFIG. = data.getUint8(offset); + offset++; + FAILSAFE_CONFIG. = data.getUint16(offset); + offset += 2; + FAILSAFE_CONFIG. = data.getUint16(offset); + offset += 2; + FAILSAFE_CONFIG. = data.getUint16(offset); + offset += 2; + FAILSAFE_CONFIG. = data.getUint16(offset); + offset += 2; + FAILSAFE_CONFIG. = data.getUint16(offset); + offset += 2; + FAILSAFE_CONFIG. = data.getUint8(offset); + offset++; + +*/ + + + break; case MSPCodes.MSP_SET_TRANSPONDER_CONFIG: diff --git a/tabs/failsafe.html b/tabs/failsafe.html index 185d8065..5f0f9c78 100644 --- a/tabs/failsafe.html +++ b/tabs/failsafe.html @@ -109,9 +109,87 @@ + + +
+ +
+
+ +
+
+
+ +
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/tabs/failsafe.js b/tabs/failsafe.js index 3ceccb1c..f67098d7 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -227,6 +227,14 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { $('input[name="failsafe_throttle_low_delay"]').val(FAILSAFE_CONFIG.failsafe_throttle_low_delay); $('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay); + // Raw basics; needs a lot of treatment to be better -- SLG + alert('failsafe_stick_motion_threshold: ' + FAILSAFE_CONFIG.failsafe_stick_motion_threshold); + alert('failsafe_min_distance: ' + FAILSAFE_CONFIG.failsafe_min_distance); + + $('input[name="failsafe_min_distance"]').val(FAILSAFE_CONFIG.failsafe_min_distance); + $('input[name="failsafe_min_distance_procedure"]').val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); + + // set stage 2 failsafe procedure $('input[type="radio"].procedure').change(function () { var element = $(this), @@ -294,6 +302,10 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { FAILSAFE_CONFIG.failsafe_throttle_low_delay = parseInt($('input[name="failsafe_throttle_low_delay"]').val()); FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val()); + FAILSAFE_CONFIG.failsafe_min_distance = parseInt($('input[name="failsafe_min_distance"]').val()); + FAILSAFE_CONFIG.failsafe_min_distance_procedure = parseInt($('input[name="failsafe_min_distance_procedure"]').val()); + + if ($('input[id="land"]').is(':checked')) { FAILSAFE_CONFIG.failsafe_procedure = 0; } else if ($('input[id="drop"]').is(':checked')) { From 2ddcd38a48abddfd257dc284620f96995fe28e79 Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Fri, 6 Oct 2017 08:27:00 -0700 Subject: [PATCH 02/12] Working dropdown for minimum distance procedure. * Needs to look tidier * Needs help annotations * needs controlling checkbox --- js/fc.js | 9 ++++++++- tabs/failsafe.html | 26 +++++++++++--------------- tabs/failsafe.js | 33 ++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/js/fc.js b/js/fc.js index a4ea24d7..1d67a931 100644 --- a/js/fc.js +++ b/js/fc.js @@ -378,7 +378,6 @@ var FC = { failsafe_throttle_low_delay: 0, failsafe_procedure: 0, failsafe_recovery_delay: 0, - failsafe_fw_roll_angle: 0, failsafe_fw_pitch_angle: 0, failsafe_fw_yaw_rate: 0, @@ -895,5 +894,13 @@ var FC = { }, getRthAltControlMode: function () { return ["Current", "Extra", "Fixed", "Max", "At Least"]; + }, + getFailsafeProcedure: function () { + return [ + "Land", + "Drop", + "RTH", + "Do Nothing", + ]; } }; diff --git a/tabs/failsafe.html b/tabs/failsafe.html index 5f0f9c78..ff7a6b49 100644 --- a/tabs/failsafe.html +++ b/tabs/failsafe.html @@ -111,23 +111,19 @@
-
+
-
-
- -
-
-
- -
-
+
+ +
+
+ + +
@@ -189,7 +185,7 @@ - +
diff --git a/tabs/failsafe.js b/tabs/failsafe.js index f67098d7..86466fdb 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -75,6 +75,8 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { // translate to user-selected language localize(); + var $failsafeMinDistanceProcedure = $('#failsafe_min_distance_procedure'); + // generate labels for assigned aux modes var auxAssignment = [], i, @@ -228,12 +230,11 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { $('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay); // Raw basics; needs a lot of treatment to be better -- SLG - alert('failsafe_stick_motion_threshold: ' + FAILSAFE_CONFIG.failsafe_stick_motion_threshold); - alert('failsafe_min_distance: ' + FAILSAFE_CONFIG.failsafe_min_distance); + //alert('failsafe_stick_motion_threshold: ' + FAILSAFE_CONFIG.failsafe_stick_motion_threshold); + //alert('failsafe_min_distance: ' + FAILSAFE_CONFIG.failsafe_min_distance); $('input[name="failsafe_min_distance"]').val(FAILSAFE_CONFIG.failsafe_min_distance); - $('input[name="failsafe_min_distance_procedure"]').val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); - + //$('input[name="failsafe_min_distance_procedure"]').val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); // set stage 2 failsafe procedure $('input[type="radio"].procedure').change(function () { @@ -284,6 +285,28 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { // set stage 2 kill switch option $('input[name="failsafe_kill_switch"]').prop('checked', FAILSAFE_CONFIG.failsafe_kill_switch); + + + + + + + + // Alternate, minimum distance failsafe procedure + GUI.fillSelect($failsafeMinDistanceProcedure, FC.getFailsafeProcedure(), FAILSAFE_CONFIG.failsafe_min_distance_procedure); + $failsafeMinDistanceProcedure.val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); + $failsafeMinDistanceProcedure.change(function () { + FAILSAFE_CONFIG.failsafe_min_distance_procedure = $failsafeMinDistanceProcedure.val(); + }); + + + + + + + + + $('a.save').click(function () { // gather data that doesn't have automatic change event bound RX_CONFIG.rx_min_usec = parseInt($('input[name="rx_min_usec"]').val()); @@ -303,7 +326,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val()); FAILSAFE_CONFIG.failsafe_min_distance = parseInt($('input[name="failsafe_min_distance"]').val()); - FAILSAFE_CONFIG.failsafe_min_distance_procedure = parseInt($('input[name="failsafe_min_distance_procedure"]').val()); + //FAILSAFE_CONFIG.failsafe_min_distance_procedure = parseInt($('input[name="failsafe_min_distance_procedure"]').val()); if ($('input[id="land"]').is(':checked')) { From f642024886bcdfd5d4a7135f37763f220d2c8105 Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Sat, 7 Oct 2017 00:19:40 -0700 Subject: [PATCH 03/12] I believe this is now fully working. It needs some spacing/comments cleanup I think, and I need some guidance about version limiting its display. I don't know what the next version is, etc. --- _locales/en/messages.json | 15 ++++++++++-- src/css/tabs/failsafe.css | 6 +++++ tabs/failsafe.html | 21 ++++++++++++---- tabs/failsafe.js | 51 ++++++++++++++++++++++++--------------- 4 files changed, 66 insertions(+), 27 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 514ba2fe..7852abb4 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1724,15 +1724,26 @@ - + "failsafeUseMinimumDistanceItem": { + "message": "Use alternate Minimum Distance Failsafe Procedure when close to Home" + }, + "failsafeUseMinimumDistanceHelp": { + "message": "Set this option if you need an alternate failsafe behavior when the craft is close to Home. For example the author of the feature has a plane that failsafes when the wings detach on landing, when the RTH failsafe behavior normally desired in flight is no longer wanted or needed." + }, "failsafeMinDistanceItem": { "message": "Failsafe Minimum Distance" }, + "failsafeMinDistanceHelp": { + "message": "The craft will use the alternate failsafe behavior when it is between 0 and this minimum distance in meters away from Home. For example if set to 20 meters, if the craft is at 13 meters the Failsafe Minimum Distance Procedure will be followed. At 25 meters, the normal failsafe procedure will be followed. If set to 0, the normal failsafe procedure will be used at all times. " + }, + "failsafeMinDistanceProcedureItem": { "message": "Failsafe Minimum Distance Procedure" }, - + "failsafeMinDistanceProcedureHelp": { + "message": "This is the failsafe procedure that will be followed when the craft is closer than the Minimum Distance from Home." + }, diff --git a/src/css/tabs/failsafe.css b/src/css/tabs/failsafe.css index 7b5ee035..ea96ec14 100644 --- a/src/css/tabs/failsafe.css +++ b/src/css/tabs/failsafe.css @@ -253,6 +253,12 @@ height: 90px; } +.tab-failsafe .minimumDistance { + width: 100px !important; + padding-left: 3px; + margin-right: 11px; +} + @media only screen and (max-width: 1055px) , only screen and (max-device-width: 1055px) { } diff --git a/tabs/failsafe.html b/tabs/failsafe.html index ff7a6b49..c4d0b0ef 100644 --- a/tabs/failsafe.html +++ b/tabs/failsafe.html @@ -111,18 +111,29 @@
-
+
-
-
+ +
+
-
- +
+ +
diff --git a/tabs/failsafe.js b/tabs/failsafe.js index 86466fdb..e1943b9a 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -75,6 +75,12 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { // translate to user-selected language localize(); + var $failsafeUseMinimumDistanceCheckbox = $('#failsafe_use_minimum_distance'); + + var $failsafeMinDistanceElements = $('#failsafe_min_distance_elements') + var $failsafeMinDistance = $('#failsafe_min_distance') + + var $failsafeMinDistanceProcedureElements = $('#failsafe_min_distance_procedure_elements') var $failsafeMinDistanceProcedure = $('#failsafe_min_distance_procedure'); // generate labels for assigned aux modes @@ -211,7 +217,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { isFailsafeEnabled = bit_check(BF_CONFIG.features, 8); } - // fill stage 2 fields + // Change Failsafe Procedure Minimum Distance appropriately when checkbox manipulated failsafeFeature = $('input[name="failsafe_feature_new"]'); failsafeFeature.change(function () { if ($(this).is(':checked')) { @@ -228,13 +234,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { $('input[name="failsafe_off_delay"]').val(FAILSAFE_CONFIG.failsafe_off_delay); $('input[name="failsafe_throttle_low_delay"]').val(FAILSAFE_CONFIG.failsafe_throttle_low_delay); $('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay); - - // Raw basics; needs a lot of treatment to be better -- SLG - //alert('failsafe_stick_motion_threshold: ' + FAILSAFE_CONFIG.failsafe_stick_motion_threshold); - //alert('failsafe_min_distance: ' + FAILSAFE_CONFIG.failsafe_min_distance); - $('input[name="failsafe_min_distance"]').val(FAILSAFE_CONFIG.failsafe_min_distance); - //$('input[name="failsafe_min_distance_procedure"]').val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); // set stage 2 failsafe procedure $('input[type="radio"].procedure').change(function () { @@ -285,12 +285,31 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { // set stage 2 kill switch option $('input[name="failsafe_kill_switch"]').prop('checked', FAILSAFE_CONFIG.failsafe_kill_switch); + // Adjust Minimum Distance values when checkbox is checked/unchecked + $failsafeUseMinimumDistanceCheckbox.change(function() { + if ($(this).is(':checked')) { + // 20 meters seems like a reasonable default for a minimum distance + $failsafeMinDistance.val(20); + $failsafeMinDistanceElements.show(); + $failsafeMinDistanceProcedureElements.show(); + } else { + // If they uncheck it, clear the distance to 0, which disables this feature + $failsafeMinDistance.val(0); + $failsafeMinDistanceElements.hide(); + $failsafeMinDistanceProcedureElements.hide(); + } + }) - - - - - + // Set initial state of controls according to data + if (FAILSAFE_CONFIG.failsafe_min_distance > 0) { + $failsafeUseMinimumDistanceCheckbox.prop('checked', true); + $failsafeMinDistanceElements.show(); + $failsafeMinDistanceProcedureElements.show(); + } else { + $failsafeUseMinimumDistanceCheckbox.prop('checked', false); + $failsafeMinDistanceElements.hide(); + $failsafeMinDistanceProcedureElements.hide(); + } // Alternate, minimum distance failsafe procedure GUI.fillSelect($failsafeMinDistanceProcedure, FC.getFailsafeProcedure(), FAILSAFE_CONFIG.failsafe_min_distance_procedure); @@ -299,14 +318,6 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { FAILSAFE_CONFIG.failsafe_min_distance_procedure = $failsafeMinDistanceProcedure.val(); }); - - - - - - - - $('a.save').click(function () { // gather data that doesn't have automatic change event bound RX_CONFIG.rx_min_usec = parseInt($('input[name="rx_min_usec"]').val()); From 9edac50952506935c78c93583c7c41590ded4ba3 Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Sat, 7 Oct 2017 22:20:10 -0700 Subject: [PATCH 04/12] Cleaning up some whitespace, adding comments to make clear where I still have questions. --- _locales/en/messages.json | 10 +--------- js/fc.js | 12 ++++++------ js/msp/MSPHelper.js | 28 ++++------------------------ tabs/failsafe.html | 9 +-------- tabs/failsafe.js | 5 ----- 5 files changed, 12 insertions(+), 52 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7852abb4..cc22f255 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1721,32 +1721,24 @@ "failsafeKillSwitchHelp": { "message": "Set this option to make the failsafe switch, configured in the modes tab, act as a direct kill switch, bypassing the selected failsafe procedure. Note: Arming is blocked with the failsafe kill switch in the ON position" }, - - - "failsafeUseMinimumDistanceItem": { "message": "Use alternate Minimum Distance Failsafe Procedure when close to Home" }, "failsafeUseMinimumDistanceHelp": { "message": "Set this option if you need an alternate failsafe behavior when the craft is close to Home. For example the author of the feature has a plane that failsafes when the wings detach on landing, when the RTH failsafe behavior normally desired in flight is no longer wanted or needed." }, - "failsafeMinDistanceItem": { "message": "Failsafe Minimum Distance" }, "failsafeMinDistanceHelp": { "message": "The craft will use the alternate failsafe behavior when it is between 0 and this minimum distance in meters away from Home. For example if set to 20 meters, if the craft is at 13 meters the Failsafe Minimum Distance Procedure will be followed. At 25 meters, the normal failsafe procedure will be followed. If set to 0, the normal failsafe procedure will be used at all times. " }, - "failsafeMinDistanceProcedureItem": { "message": "Failsafe Minimum Distance Procedure" }, "failsafeMinDistanceProcedureHelp": { "message": "This is the failsafe procedure that will be followed when the craft is closer than the Minimum Distance from Home." - }, - - - + }, "mainHelpArmed": { "message": "Motor Arming" }, diff --git a/js/fc.js b/js/fc.js index 1d67a931..b16e36fa 100644 --- a/js/fc.js +++ b/js/fc.js @@ -896,11 +896,11 @@ var FC = { return ["Current", "Extra", "Fixed", "Max", "At Least"]; }, getFailsafeProcedure: function () { - return [ - "Land", - "Drop", - "RTH", - "Do Nothing", - ]; + return { + 0: "Land", + 1: "Drop", + 2: "RTH", + 3: "Do Nothing", + } } }; diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 7865c57e..a9583bd7 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -619,7 +619,6 @@ var mspHelper = (function (gui) { offset++; FAILSAFE_CONFIG.failsafe_recovery_delay = data.getUint8(offset); offset++; - FAILSAFE_CONFIG.failsafe_fw_roll_angle = data.getUint16(offset, true); offset += 2; FAILSAFE_CONFIG.failsafe_fw_pitch_angle = data.getUint16(offset, true); @@ -632,10 +631,8 @@ var mspHelper = (function (gui) { offset += 2; FAILSAFE_CONFIG.failsafe_min_distance_procedure = data.getUint8(offset); offset++; - break; - case MSPCodes.MSP_RXFAIL_CONFIG: //noinspection JSUndeclaredVariable RXFAIL_CONFIG = []; // empty the array as new data is coming in @@ -1215,7 +1212,10 @@ var mspHelper = (function (gui) { // API version check needed here? //if (semver.gte(CONFIG.apiVersion, "1.21.0")) { - + // Or + // if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) { + // + // Guidance wanted... buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); @@ -1234,26 +1234,6 @@ var mspHelper = (function (gui) { buffer.push(FAILSAFE_CONFIG.failsafe_min_distance_procedure); //} -/* - - FAILSAFE_CONFIG. = data.getUint8(offset); - offset++; - FAILSAFE_CONFIG. = data.getUint16(offset); - offset += 2; - FAILSAFE_CONFIG. = data.getUint16(offset); - offset += 2; - FAILSAFE_CONFIG. = data.getUint16(offset); - offset += 2; - FAILSAFE_CONFIG. = data.getUint16(offset); - offset += 2; - FAILSAFE_CONFIG. = data.getUint16(offset); - offset += 2; - FAILSAFE_CONFIG. = data.getUint8(offset); - offset++; - -*/ - - break; diff --git a/tabs/failsafe.html b/tabs/failsafe.html index c4d0b0ef..097a78e7 100644 --- a/tabs/failsafe.html +++ b/tabs/failsafe.html @@ -110,10 +110,8 @@
- +
- -
@@ -135,13 +133,8 @@
-
- - - -
diff --git a/tabs/failsafe.js b/tabs/failsafe.js index e1943b9a..739dc48a 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -76,10 +76,8 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { localize(); var $failsafeUseMinimumDistanceCheckbox = $('#failsafe_use_minimum_distance'); - var $failsafeMinDistanceElements = $('#failsafe_min_distance_elements') var $failsafeMinDistance = $('#failsafe_min_distance') - var $failsafeMinDistanceProcedureElements = $('#failsafe_min_distance_procedure_elements') var $failsafeMinDistanceProcedure = $('#failsafe_min_distance_procedure'); @@ -335,10 +333,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { FAILSAFE_CONFIG.failsafe_off_delay = parseInt($('input[name="failsafe_off_delay"]').val()); FAILSAFE_CONFIG.failsafe_throttle_low_delay = parseInt($('input[name="failsafe_throttle_low_delay"]').val()); FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val()); - FAILSAFE_CONFIG.failsafe_min_distance = parseInt($('input[name="failsafe_min_distance"]').val()); - //FAILSAFE_CONFIG.failsafe_min_distance_procedure = parseInt($('input[name="failsafe_min_distance_procedure"]').val()); - if ($('input[id="land"]').is(':checked')) { FAILSAFE_CONFIG.failsafe_procedure = 0; From 81be88311e06a7ca663e403053c8b77f6f9929ec Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Fri, 6 Oct 2017 07:03:18 -0700 Subject: [PATCH 05/12] This supports adds Configurator GUI support for Failsafe Minimum Distance. I believe everything works and is OK, but I am unclear about MSP/FC/Configurator versioning, so some of what I've done here may not be correct, or may need to be done differently. I would appreciate guidance/explanation. --- _locales/en/messages.json | 18 +++++++++ js/fc.js | 25 ++++++++++++- js/msp/MSPHelper.js | 41 ++++++++++++++++++++ src/css/tabs/failsafe.css | 6 +++ tabs/failsafe.html | 78 +++++++++++++++++++++++++++++++++++++++ tabs/failsafe.js | 43 ++++++++++++++++++++- 6 files changed, 209 insertions(+), 2 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index d0cb9187..cc22f255 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1721,6 +1721,24 @@ "failsafeKillSwitchHelp": { "message": "Set this option to make the failsafe switch, configured in the modes tab, act as a direct kill switch, bypassing the selected failsafe procedure. Note: Arming is blocked with the failsafe kill switch in the ON position" }, + "failsafeUseMinimumDistanceItem": { + "message": "Use alternate Minimum Distance Failsafe Procedure when close to Home" + }, + "failsafeUseMinimumDistanceHelp": { + "message": "Set this option if you need an alternate failsafe behavior when the craft is close to Home. For example the author of the feature has a plane that failsafes when the wings detach on landing, when the RTH failsafe behavior normally desired in flight is no longer wanted or needed." + }, + "failsafeMinDistanceItem": { + "message": "Failsafe Minimum Distance" + }, + "failsafeMinDistanceHelp": { + "message": "The craft will use the alternate failsafe behavior when it is between 0 and this minimum distance in meters away from Home. For example if set to 20 meters, if the craft is at 13 meters the Failsafe Minimum Distance Procedure will be followed. At 25 meters, the normal failsafe procedure will be followed. If set to 0, the normal failsafe procedure will be used at all times. " + }, + "failsafeMinDistanceProcedureItem": { + "message": "Failsafe Minimum Distance Procedure" + }, + "failsafeMinDistanceProcedureHelp": { + "message": "This is the failsafe procedure that will be followed when the craft is closer than the Minimum Distance from Home." + }, "mainHelpArmed": { "message": "Motor Arming" }, diff --git a/js/fc.js b/js/fc.js index 4805823a..b16e36fa 100644 --- a/js/fc.js +++ b/js/fc.js @@ -376,7 +376,14 @@ var FC = { failsafe_throttle: 0, failsafe_kill_switch: 0, failsafe_throttle_low_delay: 0, - failsafe_procedure: 0 + failsafe_procedure: 0, + failsafe_recovery_delay: 0, + failsafe_fw_roll_angle: 0, + failsafe_fw_pitch_angle: 0, + failsafe_fw_yaw_rate: 0, + failsafe_stick_motion_threshold: 0, + failsafe_min_distance: 0, + failsafe_min_distance_procedure: 0 }; FW_CONFIG = { @@ -464,6 +471,14 @@ var FC = { ); } + // Unsure which version these will actually deploy in, guidance welcome. Using 1.7.3 + // so it works for the moment. And I'm really not sure how it works anyhow + if (semver.gte(CONFIG.flightControllerVersion, '1.7.3')) { + features.push( + {bit: 30, group: 'rxFailsafeExtended', name: 'FAILSAFE_EXTENDED', haveTip: false, showNameInTip: false} + ); + } + return features.reverse(); }, isFeatureEnabled: function (featureName, features) { @@ -879,5 +894,13 @@ var FC = { }, getRthAltControlMode: function () { return ["Current", "Extra", "Fixed", "Max", "At Least"]; + }, + getFailsafeProcedure: function () { + return { + 0: "Land", + 1: "Drop", + 2: "RTH", + 3: "Do Nothing", + } } }; diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 1b0dcced..a9583bd7 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -617,6 +617,20 @@ var mspHelper = (function (gui) { offset += 2; FAILSAFE_CONFIG.failsafe_procedure = data.getUint8(offset); offset++; + FAILSAFE_CONFIG.failsafe_recovery_delay = data.getUint8(offset); + offset++; + FAILSAFE_CONFIG.failsafe_fw_roll_angle = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_fw_pitch_angle = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_fw_yaw_rate = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_stick_motion_threshold = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_min_distance = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_min_distance_procedure = data.getUint8(offset); + offset++; break; case MSPCodes.MSP_RXFAIL_CONFIG: @@ -1194,6 +1208,33 @@ var mspHelper = (function (gui) { buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay)); buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay)); buffer.push(FAILSAFE_CONFIG.failsafe_procedure); + buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay); + + // API version check needed here? + //if (semver.gte(CONFIG.apiVersion, "1.21.0")) { + // Or + // if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) { + // + // Guidance wanted... + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_min_distance)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_min_distance)); + + buffer.push(FAILSAFE_CONFIG.failsafe_min_distance_procedure); + //} + break; case MSPCodes.MSP_SET_TRANSPONDER_CONFIG: diff --git a/src/css/tabs/failsafe.css b/src/css/tabs/failsafe.css index 7b5ee035..ea96ec14 100644 --- a/src/css/tabs/failsafe.css +++ b/src/css/tabs/failsafe.css @@ -253,6 +253,12 @@ height: 90px; } +.tab-failsafe .minimumDistance { + width: 100px !important; + padding-left: 3px; + margin-right: 11px; +} + @media only screen and (max-width: 1055px) , only screen and (max-device-width: 1055px) { } diff --git a/tabs/failsafe.html b/tabs/failsafe.html index 185d8065..097a78e7 100644 --- a/tabs/failsafe.html +++ b/tabs/failsafe.html @@ -109,9 +109,87 @@
+ + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/tabs/failsafe.js b/tabs/failsafe.js index 3ceccb1c..739dc48a 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -75,6 +75,12 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { // translate to user-selected language localize(); + var $failsafeUseMinimumDistanceCheckbox = $('#failsafe_use_minimum_distance'); + var $failsafeMinDistanceElements = $('#failsafe_min_distance_elements') + var $failsafeMinDistance = $('#failsafe_min_distance') + var $failsafeMinDistanceProcedureElements = $('#failsafe_min_distance_procedure_elements') + var $failsafeMinDistanceProcedure = $('#failsafe_min_distance_procedure'); + // generate labels for assigned aux modes var auxAssignment = [], i, @@ -209,7 +215,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { isFailsafeEnabled = bit_check(BF_CONFIG.features, 8); } - // fill stage 2 fields + // Change Failsafe Procedure Minimum Distance appropriately when checkbox manipulated failsafeFeature = $('input[name="failsafe_feature_new"]'); failsafeFeature.change(function () { if ($(this).is(':checked')) { @@ -226,6 +232,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { $('input[name="failsafe_off_delay"]').val(FAILSAFE_CONFIG.failsafe_off_delay); $('input[name="failsafe_throttle_low_delay"]').val(FAILSAFE_CONFIG.failsafe_throttle_low_delay); $('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay); + $('input[name="failsafe_min_distance"]').val(FAILSAFE_CONFIG.failsafe_min_distance); // set stage 2 failsafe procedure $('input[type="radio"].procedure').change(function () { @@ -276,6 +283,39 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { // set stage 2 kill switch option $('input[name="failsafe_kill_switch"]').prop('checked', FAILSAFE_CONFIG.failsafe_kill_switch); + // Adjust Minimum Distance values when checkbox is checked/unchecked + $failsafeUseMinimumDistanceCheckbox.change(function() { + if ($(this).is(':checked')) { + // 20 meters seems like a reasonable default for a minimum distance + $failsafeMinDistance.val(20); + $failsafeMinDistanceElements.show(); + $failsafeMinDistanceProcedureElements.show(); + } else { + // If they uncheck it, clear the distance to 0, which disables this feature + $failsafeMinDistance.val(0); + $failsafeMinDistanceElements.hide(); + $failsafeMinDistanceProcedureElements.hide(); + } + }) + + // Set initial state of controls according to data + if (FAILSAFE_CONFIG.failsafe_min_distance > 0) { + $failsafeUseMinimumDistanceCheckbox.prop('checked', true); + $failsafeMinDistanceElements.show(); + $failsafeMinDistanceProcedureElements.show(); + } else { + $failsafeUseMinimumDistanceCheckbox.prop('checked', false); + $failsafeMinDistanceElements.hide(); + $failsafeMinDistanceProcedureElements.hide(); + } + + // Alternate, minimum distance failsafe procedure + GUI.fillSelect($failsafeMinDistanceProcedure, FC.getFailsafeProcedure(), FAILSAFE_CONFIG.failsafe_min_distance_procedure); + $failsafeMinDistanceProcedure.val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); + $failsafeMinDistanceProcedure.change(function () { + FAILSAFE_CONFIG.failsafe_min_distance_procedure = $failsafeMinDistanceProcedure.val(); + }); + $('a.save').click(function () { // gather data that doesn't have automatic change event bound RX_CONFIG.rx_min_usec = parseInt($('input[name="rx_min_usec"]').val()); @@ -293,6 +333,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { FAILSAFE_CONFIG.failsafe_off_delay = parseInt($('input[name="failsafe_off_delay"]').val()); FAILSAFE_CONFIG.failsafe_throttle_low_delay = parseInt($('input[name="failsafe_throttle_low_delay"]').val()); FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val()); + FAILSAFE_CONFIG.failsafe_min_distance = parseInt($('input[name="failsafe_min_distance"]').val()); if ($('input[id="land"]').is(':checked')) { FAILSAFE_CONFIG.failsafe_procedure = 0; From 9c9e7cd1426acdfde0b0935c80074e3c2582edb4 Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Sat, 7 Oct 2017 22:38:15 -0700 Subject: [PATCH 06/12] Removing accidental whitespace --- tabs/failsafe.html | 52 ---------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/tabs/failsafe.html b/tabs/failsafe.html index 097a78e7..83ca8f0c 100644 --- a/tabs/failsafe.html +++ b/tabs/failsafe.html @@ -138,58 +138,6 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
From 4feee8f48d4d1963f2b1e4de7eb457eab4cf998a Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Sat, 7 Oct 2017 23:47:16 -0700 Subject: [PATCH 07/12] Fixing whitespace and comment issues --- tabs/failsafe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/failsafe.js b/tabs/failsafe.js index 739dc48a..78da849f 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -215,7 +215,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { isFailsafeEnabled = bit_check(BF_CONFIG.features, 8); } - // Change Failsafe Procedure Minimum Distance appropriately when checkbox manipulated + // fill stage 2 fields failsafeFeature = $('input[name="failsafe_feature_new"]'); failsafeFeature.change(function () { if ($(this).is(':checked')) { From cf1c676eaa02b7cd01c19e1facb52fd6166479a6 Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Mon, 9 Oct 2017 19:56:59 -0700 Subject: [PATCH 08/12] * Changing from meters to centimeters * Other minor tweaks to help text * Finalizing API checks --- _locales/en/messages.json | 6 +++--- js/fc.js | 8 -------- js/msp/MSPHelper.js | 32 +++++++++++++------------------- tabs/failsafe.js | 2 +- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index cc22f255..768a8cbd 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1728,16 +1728,16 @@ "message": "Set this option if you need an alternate failsafe behavior when the craft is close to Home. For example the author of the feature has a plane that failsafes when the wings detach on landing, when the RTH failsafe behavior normally desired in flight is no longer wanted or needed." }, "failsafeMinDistanceItem": { - "message": "Failsafe Minimum Distance" + "message": "Failsafe Minimum Distance in centimeters" }, "failsafeMinDistanceHelp": { - "message": "The craft will use the alternate failsafe behavior when it is between 0 and this minimum distance in meters away from Home. For example if set to 20 meters, if the craft is at 13 meters the Failsafe Minimum Distance Procedure will be followed. At 25 meters, the normal failsafe procedure will be followed. If set to 0, the normal failsafe procedure will be used at all times. " + "message": "The craft will use the alternate failsafe behavior when it is between 0 and this minimum distance in centimeters away from Home. For example if set to 2000 centimeters (20 meters), and the craft is at 13 meters, the Failsafe Minimum Distance Procedure will be followed. When the craft is at 25 meters, the normal failsafe procedure will be followed. If set to 0, the normal failsafe procedure will be used at all times. " }, "failsafeMinDistanceProcedureItem": { "message": "Failsafe Minimum Distance Procedure" }, "failsafeMinDistanceProcedureHelp": { - "message": "This is the failsafe procedure that will be followed when the craft is closer than the Minimum Distance from Home." + "message": "This is the failsafe procedure that will be followed when the craft is closer than the Failsafe Minimum Distance from Home." }, "mainHelpArmed": { "message": "Motor Arming" diff --git a/js/fc.js b/js/fc.js index b16e36fa..b5bbe89f 100644 --- a/js/fc.js +++ b/js/fc.js @@ -471,14 +471,6 @@ var FC = { ); } - // Unsure which version these will actually deploy in, guidance welcome. Using 1.7.3 - // so it works for the moment. And I'm really not sure how it works anyhow - if (semver.gte(CONFIG.flightControllerVersion, '1.7.3')) { - features.push( - {bit: 30, group: 'rxFailsafeExtended', name: 'FAILSAFE_EXTENDED', haveTip: false, showNameInTip: false} - ); - } - return features.reverse(); }, isFeatureEnabled: function (featureName, features) { diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index a9583bd7..a29562cf 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1210,30 +1210,24 @@ var mspHelper = (function (gui) { buffer.push(FAILSAFE_CONFIG.failsafe_procedure); buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay); - // API version check needed here? - //if (semver.gte(CONFIG.apiVersion, "1.21.0")) { - // Or - // if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) { - // - // Guidance wanted... + if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) { + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_min_distance)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_min_distance)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_min_distance)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_min_distance)); - - buffer.push(FAILSAFE_CONFIG.failsafe_min_distance_procedure); - //} + buffer.push(FAILSAFE_CONFIG.failsafe_min_distance_procedure); + } break; diff --git a/tabs/failsafe.js b/tabs/failsafe.js index 78da849f..bae3cff1 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -287,7 +287,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { $failsafeUseMinimumDistanceCheckbox.change(function() { if ($(this).is(':checked')) { // 20 meters seems like a reasonable default for a minimum distance - $failsafeMinDistance.val(20); + $failsafeMinDistance.val(2000); $failsafeMinDistanceElements.show(); $failsafeMinDistanceProcedureElements.show(); } else { From 8c1b0f462929dab839cb38648662cdfa0d32dc81 Mon Sep 17 00:00:00 2001 From: StewLG Date: Tue, 10 Oct 2017 05:26:11 -0700 Subject: [PATCH 09/12] Update MSPHelper.js Had not realized developer branch was version 1.7.4; I had started this PR on master which which was on 1.7.3. Which explains my initial confusion about what to put here. --- js/msp/MSPHelper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index a29562cf..b230e6e3 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1210,7 +1210,7 @@ var mspHelper = (function (gui) { buffer.push(FAILSAFE_CONFIG.failsafe_procedure); buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay); - if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) { + if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) { buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); From dd18679c7a836ebaa141524bb0e2ed489f86ae5b Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Tue, 10 Oct 2017 06:10:26 -0700 Subject: [PATCH 10/12] Fixing so we only protect two new variables, not the old ones. --- js/msp/MSPHelper.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index b230e6e3..5e144ec4 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1209,26 +1209,19 @@ var mspHelper = (function (gui) { buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay)); buffer.push(FAILSAFE_CONFIG.failsafe_procedure); buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay); - - if (semver.gt(CONFIG.flightControllerVersion, "1.7.3")) { - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); - - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); - - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); - - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); - + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) { buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_min_distance)); buffer.push(highByte(FAILSAFE_CONFIG.failsafe_min_distance)); - buffer.push(FAILSAFE_CONFIG.failsafe_min_distance_procedure); } - break; case MSPCodes.MSP_SET_TRANSPONDER_CONFIG: From 774d1c97e6ee2f201daeb1babd8d79d928355bec Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Tue, 10 Oct 2017 06:19:57 -0700 Subject: [PATCH 11/12] Guarding existing variables which were introduced in 1.7.3, but never implemented in the configurator until now. Note that these are for the moment just passive passengers -- there's no UI in the configurator to edit them yet. --- js/msp/MSPHelper.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 5e144ec4..13a78881 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1208,15 +1208,17 @@ var mspHelper = (function (gui) { buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay)); buffer.push(highByte(FAILSAFE_CONFIG.failsafe_throttle_low_delay)); buffer.push(FAILSAFE_CONFIG.failsafe_procedure); - buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); - buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); - buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) { + buffer.push(FAILSAFE_CONFIG.failsafe_recovery_delay); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_roll_angle)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_pitch_angle)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_fw_yaw_rate)); + buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + buffer.push(highByte(FAILSAFE_CONFIG.failsafe_stick_motion_threshold)); + } if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) { buffer.push(lowByte(FAILSAFE_CONFIG.failsafe_min_distance)); buffer.push(highByte(FAILSAFE_CONFIG.failsafe_min_distance)); From 0c1b48351e0680404651684ad460860d216d9b33 Mon Sep 17 00:00:00 2001 From: Stewart Loving-Gibbard Date: Tue, 10 Oct 2017 09:43:13 -0700 Subject: [PATCH 12/12] * Properly guarding JS on for new variables introduced in 1.7.3/1.7.4 * Properly hiding/showing relevant controls for Minimum Failsafe Distance according to version (>= 1.7.4) * Fixing bad maximum for centimeters distance --- js/msp/MSPHelper.js | 32 +++++++++++++----------- tabs/failsafe.html | 8 +++--- tabs/failsafe.js | 59 ++++++++++++++++++++++++++------------------- 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 13a78881..9642a7b2 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -617,20 +617,24 @@ var mspHelper = (function (gui) { offset += 2; FAILSAFE_CONFIG.failsafe_procedure = data.getUint8(offset); offset++; - FAILSAFE_CONFIG.failsafe_recovery_delay = data.getUint8(offset); - offset++; - FAILSAFE_CONFIG.failsafe_fw_roll_angle = data.getUint16(offset, true); - offset += 2; - FAILSAFE_CONFIG.failsafe_fw_pitch_angle = data.getUint16(offset, true); - offset += 2; - FAILSAFE_CONFIG.failsafe_fw_yaw_rate = data.getUint16(offset, true); - offset += 2; - FAILSAFE_CONFIG.failsafe_stick_motion_threshold = data.getUint16(offset, true); - offset += 2; - FAILSAFE_CONFIG.failsafe_min_distance = data.getUint16(offset, true); - offset += 2; - FAILSAFE_CONFIG.failsafe_min_distance_procedure = data.getUint8(offset); - offset++; + if (semver.gte(CONFIG.flightControllerVersion, "1.7.3")) { + FAILSAFE_CONFIG.failsafe_recovery_delay = data.getUint8(offset); + offset++; + FAILSAFE_CONFIG.failsafe_fw_roll_angle = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_fw_pitch_angle = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_fw_yaw_rate = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_stick_motion_threshold = data.getUint16(offset, true); + offset += 2; + } + if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) { + FAILSAFE_CONFIG.failsafe_min_distance = data.getUint16(offset, true); + offset += 2; + FAILSAFE_CONFIG.failsafe_min_distance_procedure = data.getUint8(offset); + offset++; + } break; case MSPCodes.MSP_RXFAIL_CONFIG: diff --git a/tabs/failsafe.html b/tabs/failsafe.html index 83ca8f0c..274c63c9 100644 --- a/tabs/failsafe.html +++ b/tabs/failsafe.html @@ -109,9 +109,8 @@
- - -
+ +
@@ -122,7 +121,7 @@
-
@@ -134,7 +133,6 @@
-
diff --git a/tabs/failsafe.js b/tabs/failsafe.js index bc26c2ba..8a648bc8 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -231,7 +231,9 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { $('input[name="failsafe_off_delay"]').val(FAILSAFE_CONFIG.failsafe_off_delay); $('input[name="failsafe_throttle_low_delay"]').val(FAILSAFE_CONFIG.failsafe_throttle_low_delay); $('input[name="failsafe_delay"]').val(FAILSAFE_CONFIG.failsafe_delay); - $('input[name="failsafe_min_distance"]').val(FAILSAFE_CONFIG.failsafe_min_distance); + if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) { + $('input[name="failsafe_min_distance"]').val(FAILSAFE_CONFIG.failsafe_min_distance); + } // set stage 2 failsafe procedure $('input[type="radio"].procedure').change(function () { @@ -282,39 +284,44 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { // set stage 2 kill switch option $('input[name="failsafe_kill_switch"]').prop('checked', FAILSAFE_CONFIG.failsafe_kill_switch); - // Adjust Minimum Distance values when checkbox is checked/unchecked - $failsafeUseMinimumDistanceCheckbox.change(function() { - if ($(this).is(':checked')) { - // 20 meters seems like a reasonable default for a minimum distance - $failsafeMinDistance.val(2000); + if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) { + // Adjust Minimum Distance values when checkbox is checked/unchecked + $failsafeUseMinimumDistanceCheckbox.change(function() { + if ($(this).is(':checked')) { + // 20 meters seems like a reasonable default for a minimum distance + $failsafeMinDistance.val(2000); + $failsafeMinDistanceElements.show(); + $failsafeMinDistanceProcedureElements.show(); + } else { + // If they uncheck it, clear the distance to 0, which disables this feature + $failsafeMinDistance.val(0); + $failsafeMinDistanceElements.hide(); + $failsafeMinDistanceProcedureElements.hide(); + } + }); + + // Set initial state of controls according to data + if (FAILSAFE_CONFIG.failsafe_min_distance > 0) { + $failsafeUseMinimumDistanceCheckbox.prop('checked', true); $failsafeMinDistanceElements.show(); $failsafeMinDistanceProcedureElements.show(); } else { - // If they uncheck it, clear the distance to 0, which disables this feature - $failsafeMinDistance.val(0); + $failsafeUseMinimumDistanceCheckbox.prop('checked', false); $failsafeMinDistanceElements.hide(); $failsafeMinDistanceProcedureElements.hide(); } - }) - // Set initial state of controls according to data - if (FAILSAFE_CONFIG.failsafe_min_distance > 0) { - $failsafeUseMinimumDistanceCheckbox.prop('checked', true); - $failsafeMinDistanceElements.show(); - $failsafeMinDistanceProcedureElements.show(); + // Alternate, minimum distance failsafe procedure + GUI.fillSelect($failsafeMinDistanceProcedure, FC.getFailsafeProcedure(), FAILSAFE_CONFIG.failsafe_min_distance_procedure); + $failsafeMinDistanceProcedure.val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); + $failsafeMinDistanceProcedure.change(function () { + FAILSAFE_CONFIG.failsafe_min_distance_procedure = $failsafeMinDistanceProcedure.val(); + }); + $('.requires-v1_7_4').show(); } else { - $failsafeUseMinimumDistanceCheckbox.prop('checked', false); - $failsafeMinDistanceElements.hide(); - $failsafeMinDistanceProcedureElements.hide(); + $('.requires-v1_7_4').hide(); } - // Alternate, minimum distance failsafe procedure - GUI.fillSelect($failsafeMinDistanceProcedure, FC.getFailsafeProcedure(), FAILSAFE_CONFIG.failsafe_min_distance_procedure); - $failsafeMinDistanceProcedure.val(FAILSAFE_CONFIG.failsafe_min_distance_procedure); - $failsafeMinDistanceProcedure.change(function () { - FAILSAFE_CONFIG.failsafe_min_distance_procedure = $failsafeMinDistanceProcedure.val(); - }); - $('a.save').click(function () { // gather data that doesn't have automatic change event bound RX_CONFIG.rx_min_usec = parseInt($('input[name="rx_min_usec"]').val()); @@ -332,7 +339,9 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { FAILSAFE_CONFIG.failsafe_off_delay = parseInt($('input[name="failsafe_off_delay"]').val()); FAILSAFE_CONFIG.failsafe_throttle_low_delay = parseInt($('input[name="failsafe_throttle_low_delay"]').val()); FAILSAFE_CONFIG.failsafe_delay = parseInt($('input[name="failsafe_delay"]').val()); - FAILSAFE_CONFIG.failsafe_min_distance = parseInt($('input[name="failsafe_min_distance"]').val()); + if (semver.gte(CONFIG.flightControllerVersion, "1.7.4")) { + FAILSAFE_CONFIG.failsafe_min_distance = parseInt($('input[name="failsafe_min_distance"]').val()); + } if ($('input[id="land"]').is(':checked')) { FAILSAFE_CONFIG.failsafe_procedure = 0;