Skip to content

Commit 9b268d5

Browse files
committed
Cracked it!
I've got it working with not timeouts or any of that nonsense. There was a call to loadHTML mid MSP chain that was screwing everything up. After silencing that, everything works.
1 parent 780ab3b commit 9b268d5

File tree

2 files changed

+33
-23
lines changed

2 files changed

+33
-23
lines changed

js/defaults_dialog.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
var helper = helper || {};
55
var savingDefaultsModal;
6+
var processingDefaults = false;
67

78
helper.defaultsDialog = (function () {
89

@@ -1130,6 +1131,7 @@ helper.defaultsDialog = (function () {
11301131
};
11311132

11321133
privateScope.finalize = function (selectedDefaultPreset) {
1134+
processingDefaults = false;
11331135
mspHelper.saveToEeprom(function () {
11341136
//noinspection JSUnresolvedVariable
11351137
GUI.log(chrome.i18n.getMessage('configurationEepromSaved'));
@@ -1206,9 +1208,6 @@ helper.defaultsDialog = (function () {
12061208
]);
12071209
}
12081210

1209-
settingsChainer.setChain(miscChain);
1210-
settingsChainer.execute();
1211-
12121211
// Set profiles
12131212

12141213
for (let ps = 0; ps < 3; ps++) {
@@ -1242,20 +1241,29 @@ helper.defaultsDialog = (function () {
12421241
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, callback);
12431242
});
12441243

1244+
12451245
for (let pc = 0; pc < 3; pc++) {
12461246
profileChainer[pc].setChain(profileChain[pc]);
1247+
1248+
if (pc < 2) {
1249+
profileChainer[pc].setExitPoint(function () {
1250+
profileChainer[pc+1].execute();
1251+
});
1252+
}
12471253
}
12481254

1255+
processingDefaults = true;
1256+
settingsChainer.setChain(miscChain);
1257+
settingsChainer.setExitPoint(function () {
1258+
updateActivatedTab();
1259+
profileChainer[0].execute();
1260+
});
1261+
settingsChainer.execute();
1262+
12491263
profileChainer[2].setExitPoint(function () {
1264+
updateActivatedTab();
12501265
privateScope.finalize(selectedDefaultPreset);
12511266
});
1252-
1253-
let timeout = (miscChain.length * 250) + 7000;
1254-
let timeOut0 = setTimeout(profileChainer[0].execute, timeout);
1255-
timeout+= (profileChain[0].length * 250) + 5000;
1256-
let timeOut1 = setTimeout(profileChainer[1].execute, timeout);
1257-
timeout+= (profileChain[1].length * 250) + 5000;
1258-
let timeOut2 = setTimeout(profileChainer[2].execute, timeout);
12591267
}
12601268

12611269
privateScope.onPresetClick = function (event) {

js/gui.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,22 @@ GUI_control.prototype.updateStatusBar = function() {
261261
};
262262

263263
GUI_control.prototype.updateProfileChange = function(refresh) {
264-
$('#mixerprofilechange').val(CONFIG.mixer_profile);
265-
$('#profilechange').val(CONFIG.profile);
266-
$('#batteryprofilechange').val(CONFIG.battery_profile);
267-
if (refresh > 0) {
268-
if (refresh & mspHelper.PROFILES_CHANGED.MIXER) {
269-
GUI.log(chrome.i18n.getMessage('loadedMixerProfile', [CONFIG.mixer_profile + 1]));
270-
}
271-
if (refresh & mspHelper.PROFILES_CHANGED.CONTROL) {
272-
GUI.log(chrome.i18n.getMessage('pidTuning_LoadedProfile', [CONFIG.profile + 1]));
273-
}
274-
if (refresh & mspHelper.PROFILES_CHANGED.BATTERY) {
275-
GUI.log(chrome.i18n.getMessage('loadedBatteryProfile', [CONFIG.battery_profile + 1]));
264+
if ((processingDefaults != undefined && processingDefaults === true) === false) {
265+
$('#mixerprofilechange').val(CONFIG.mixer_profile);
266+
$('#profilechange').val(CONFIG.profile);
267+
$('#batteryprofilechange').val(CONFIG.battery_profile);
268+
if (refresh > 0) {
269+
if (refresh & mspHelper.PROFILES_CHANGED.MIXER) {
270+
GUI.log(chrome.i18n.getMessage('loadedMixerProfile', [CONFIG.mixer_profile + 1]));
271+
}
272+
if (refresh & mspHelper.PROFILES_CHANGED.CONTROL) {
273+
GUI.log(chrome.i18n.getMessage('pidTuning_LoadedProfile', [CONFIG.profile + 1]));
274+
}
275+
if (refresh & mspHelper.PROFILES_CHANGED.BATTERY) {
276+
GUI.log(chrome.i18n.getMessage('loadedBatteryProfile', [CONFIG.battery_profile + 1]));
277+
}
278+
updateActivatedTab();
276279
}
277-
updateActivatedTab();
278280
}
279281
};
280282

0 commit comments

Comments
 (0)