Skip to content

Commit 1affa6e

Browse files
atomgombachmelevskij
authored andcommitted
Enable GPS Rescue UI if used as a mode (betaflight#3611)
Enabled GPS Rescue UI if used as a mode
1 parent 9a6cdbb commit 1affa6e

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/js/tabs/failsafe.js

+23-14
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ failsafe.initialize = function (callback) {
9494
// generate labels for assigned aux modes
9595
const auxAssignment = [];
9696

97-
let element;
98-
9997
for (let channelIndex = 0; channelIndex < FC.RC.active_channels - 4; channelIndex++) {
10098
auxAssignment.push("");
10199
}
@@ -104,6 +102,7 @@ failsafe.initialize = function (callback) {
104102
auxAssignment[FC.RSSI_CONFIG.channel - 5] += "<span class=\"modename\">" + "RSSI" + "</span>"; // Aux channels start at 5 in backend so we have to substract 5
105103
}
106104

105+
let hasGpsRescueAsMode = false;
107106
for (let modeIndex = 0; modeIndex < FC.AUX_CONFIG.length; modeIndex++) {
108107

109108
const modeId = FC.AUX_CONFIG_IDS[modeIndex];
@@ -123,6 +122,10 @@ failsafe.initialize = function (callback) {
123122

124123
// Search for the real name if it belongs to a peripheral
125124
let modeName = FC.AUX_CONFIG[modeIndex];
125+
// Check if GPS Rescue is enabled as a mode
126+
if (!hasGpsRescueAsMode && modeName === "GPS RESCUE") {
127+
hasGpsRescueAsMode = true;
128+
}
126129
modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName);
127130

128131
auxAssignment[modeRange.auxChannelIndex] += `<span class="modename">${modeName}</span>`;
@@ -232,28 +235,34 @@ failsafe.initialize = function (callback) {
232235
$('input[name="failsafe_delay"]').val((FC.FAILSAFE_CONFIG.failsafe_delay / 10.0).toFixed(1));
233236

234237
// set stage 2 failsafe procedure
235-
$('input[type="radio"].procedure').change(function () {
238+
const rescueSettings = $('input[id="gps_rescue"]').parent().parent().find(':input');
239+
$('input[type="radio"].procedure').on("change", function () {
236240
// Disable all the settings
237-
$('.proceduresettings :input').attr('disabled',true);
241+
$('.proceduresettings :input').attr('disabled', true);
238242
// Enable only selected
239-
$(this).parent().parent().find(':input').attr('disabled',false);
243+
$(this).parent().parent().find(':input').attr('disabled', false);
244+
// Also enable GPS Rescue if configured as a mode
245+
if (hasGpsRescueAsMode) {
246+
rescueSettings.attr('disabled', false);
247+
}
240248
});
241249

250+
let radio;
242251
switch(FC.FAILSAFE_CONFIG.failsafe_procedure) {
243252
case 0:
244-
element = $('input[id="land"]') ;
245-
element.prop('checked', true);
246-
element.change();
253+
radio = $('input[id="land"]') ;
254+
radio.prop('checked', true);
255+
radio.trigger("change");
247256
break;
248257
case 1:
249-
element = $('input[id="drop"]');
250-
element.prop('checked', true);
251-
element.change();
258+
radio = $('input[id="drop"]');
259+
radio.prop('checked', true);
260+
radio.trigger("change");
252261
break;
253262
case 2:
254-
element = $('input[id="gps_rescue"]');
255-
element.prop('checked', true);
256-
element.change();
263+
radio = $('input[id="gps_rescue"]');
264+
radio.prop('checked', true);
265+
radio.trigger("change");
257266
break;
258267
}
259268

0 commit comments

Comments
 (0)