Skip to content

Commit 8fbe25c

Browse files
committed
Updated to fix issues
1 parent 40fbbb0 commit 8fbe25c

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

js/defaults_dialog.js

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,37 +1175,6 @@ helper.defaultsDialog = (function () {
11751175

11761176
let settingsChainer = MSPChainerClass();
11771177
let miscChain = [];
1178-
1179-
for (let ps = 0; ps < 3; ps++) {
1180-
profileChain[ps].push(function (callback) {
1181-
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [ps], false, callback);
1182-
});
1183-
1184-
profileChain[ps].push(function (callback) {
1185-
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [ps], false, callback);
1186-
});
1187-
1188-
controlProfileSettings.forEach(input => {
1189-
profileChain[ps].push(function (callback) {
1190-
mspHelper.setSetting(input.key, input.value, callback);
1191-
});
1192-
});
1193-
1194-
batterySettings.forEach(input => {
1195-
profileChain[ps].push(function (callback) {
1196-
mspHelper.setSetting(input.key, input.value, callback);
1197-
});
1198-
});
1199-
}
1200-
1201-
// Resetting profile at end of profile 3
1202-
profileChain[2].push(function (callback) {
1203-
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [currentControlProfile], false, callback);
1204-
});
1205-
1206-
profileChain[2].push(function (callback) {
1207-
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, callback);
1208-
});
12091178

12101179
miscSettings.forEach(input => {
12111180
miscChain.push(function (callback) {
@@ -1237,19 +1206,56 @@ helper.defaultsDialog = (function () {
12371206
]);
12381207
}
12391208

1209+
settingsChainer.setChain(miscChain);
1210+
settingsChainer.execute();
1211+
1212+
// Set profiles
1213+
1214+
for (let ps = 0; ps < 3; ps++) {
1215+
profileChain[ps].push(function (callback) {
1216+
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [ps], false, callback);
1217+
});
1218+
1219+
profileChain[ps].push(function (callback) {
1220+
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [ps], false, callback);
1221+
});
1222+
1223+
controlProfileSettings.forEach(input => {
1224+
profileChain[ps].push(function (callback) {
1225+
mspHelper.setSetting(input.key, input.value, callback);
1226+
});
1227+
});
1228+
1229+
batterySettings.forEach(input => {
1230+
profileChain[ps].push(function (callback) {
1231+
mspHelper.setSetting(input.key, input.value, callback);
1232+
});
1233+
});
1234+
}
1235+
1236+
// Resetting profile at end of profile 3
1237+
profileChain[2].push(function (callback) {
1238+
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [currentControlProfile], false, callback);
1239+
});
1240+
1241+
profileChain[2].push(function (callback) {
1242+
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, callback);
1243+
});
1244+
12401245
for (let pc = 0; pc < 3; pc++) {
12411246
profileChainer[pc].setChain(profileChain[pc]);
12421247
}
1243-
1244-
settingsChainer.setChain(miscChain);
1245-
settingsChainer.setExitPoint(function () {
1248+
1249+
profileChainer[2].setExitPoint(function () {
12461250
privateScope.finalize(selectedDefaultPreset);
12471251
});
1248-
1249-
let timeOut0 = setTimeout(profileChainer[0].execute, 4000);
1250-
let timeOut1 = setTimeout(profileChainer[1].execute, 14000);
1251-
let timeOut2 = setTimeout(profileChainer[2].execute, 24000);
1252-
let timeOut3 = setTimeout(settingsChainer.execute, 34000);
1252+
1253+
let timeout = (miscChain.length * 150) + 2000;
1254+
let timeOut0 = setTimeout(profileChainer[0].execute, timeout);
1255+
timeout+= (profileChain[0].length * 150) + 4000;
1256+
let timeOut1 = setTimeout(profileChainer[1].execute, timeout);
1257+
timeout+= (profileChain[1].length * 150) + 4000;
1258+
let timeOut2 = setTimeout(profileChainer[2].execute, timeout);
12531259
}
12541260

12551261
privateScope.onPresetClick = function (event) {

0 commit comments

Comments
 (0)