mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-25 01:05:12 +03:00
Update auxiliary.js
Added checks for modes not in the configuratorBoxOrder array.
This commit is contained in:
parent
7a0487e816
commit
4b14deeebc
1 changed files with 30 additions and 10 deletions
|
@ -33,7 +33,7 @@ TABS.auxiliary.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function sort_modes_for_display() {
|
||||
// This array defines the order that the modes are displayed in the configurator modes page.
|
||||
// This array defines the order that the modes are displayed in the configurator modes page
|
||||
configuratorBoxOrder = [
|
||||
"ARM", // Arming
|
||||
"ANGLE", "HORIZON", "MANUAL", // Flight modes
|
||||
|
@ -49,26 +49,46 @@ TABS.auxiliary.initialize = function (callback) {
|
|||
];
|
||||
|
||||
// Sort the modes
|
||||
tmpAUX_CONFIG =[];
|
||||
tmpAUX_CONFIG_IDS = [];
|
||||
for (i=0;i<AUX_CONFIG.length;i++) {
|
||||
tmpAUX_CONFIG[i] = AUX_CONFIG[i]; // MSP_BOXNAMES
|
||||
tmpAUX_CONFIG_IDS[i] = AUX_CONFIG_IDS[i];
|
||||
|
||||
var tmpAUX_CONFIG = [];
|
||||
var tmpAUX_CONFIG_IDS =[];
|
||||
var found = false;
|
||||
var sortedID = 0;
|
||||
|
||||
for (i=0; i<AUX_CONFIG.length; i++) {
|
||||
tmpAUX_CONFIG[i] = AUX_CONFIG[i];
|
||||
tmpAUX_CONFIG_IDS[i] = AUX_CONFIG_IDS[i];
|
||||
}
|
||||
|
||||
sortedID = 0;
|
||||
AUX_CONFIG = [];
|
||||
AUX_CONFIG_IDS = [];
|
||||
|
||||
for (i=0; i<configuratorBoxOrder.length; i++) {
|
||||
for(j=0; j<tmpAUX_CONFIG.length; j++) {
|
||||
if (configuratorBoxOrder[i] === tmpAUX_CONFIG[j]) {
|
||||
AUX_CONFIG[sortedID] = tmpAUX_CONFIG[j];
|
||||
AUX_CONFIG_IDS[sortedID] = tmpAUX_CONFIG_IDS[j];
|
||||
sortedID++;
|
||||
AUX_CONFIG_IDS[sortedID++] = tmpAUX_CONFIG_IDS[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// There are modes that are missing from the configuratorBoxOrder array. Add them to the end until they are ordered correctly.
|
||||
if (tmpAUX_CONFIG.length > AUX_CONFIG.length) {
|
||||
for (i=0; i<tmpAUX_CONFIG.length; i++) {
|
||||
found = false;
|
||||
for (j=0; j<AUX_CONFIG.length; j++) {
|
||||
if (tmpAUX_CONFIG[i] === AUX_CONFIG[j]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
AUX_CONFIG[sortedID] = tmpAUX_CONFIG[i];
|
||||
AUX_CONFIG_IDS[sortedID++] = tmpAUX_CONFIG_IDS[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false, get_mode_ranges);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue