Unverified Commit 40923006 authored by Paweł Spychalski's avatar Paweł Spychalski Committed by GitHub
Browse files

Merge pull request #1100 from MrD-RC/Sort-modes-in-to-better-order_963

Sort modes in to better order 963
parents 2f733c00 4b14deee
......@@ -28,8 +28,68 @@ TABS.auxiliary.initialize = function (callback) {
}
function load_html() {
sort_modes_for_display();
GUI.load("./tabs/auxiliary.html", process_html);
}
function sort_modes_for_display() {
// This array defines the order that the modes are displayed in the configurator modes page
configuratorBoxOrder = [
"ARM", // Arming
"ANGLE", "HORIZON", "MANUAL", // Flight modes
"NAV RTH", "NAV POSHOLD", "NAV CRUISE", // Navigation mode
"NAV ALTHOLD", "HEADING HOLD", "AIR MODE", // Flight mode modifiers
"NAV WP", "GCS NAV", "HOME RESET", // Navigation
"SERVO AUTOTRIM", "AUTO TUNE", "NAV LAUNCH", "LOITER CHANGE", "FLAPERON", // Fixed wing specific
"FPV ANGLE MIX", "TURN ASSIST", "MC BRAKING", "SURFACE", "HEADFREE", "HEADADJ", // Multi-rotor specific
"BEEPER", "LEDLOW", "LIGHTS", // Feedback
"OSD SW", "OSD ALT 1", "OSD ALT 2", "OSD ALT 3", // OSD
"CAMSTAB", "CAMERA CONTROL 1", "CAMERA CONTROL 2", "CAMERA CONTROL 3", // FPV Camera
"BLACKBOX", "FAILSAFE", "KILLSWITCH", "TELEMETRY", "MSP RC OVERRIDE", "USER1", "USER2" // Misc
];
// Sort the modes
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];
}
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];
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment