1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 20:35:19 +03:00

Fix profile change not working

Initially, I thought that the profiles were not changing when you selected a new profile from the select box. It turns out that this was only happening after setting up from the defaults dialog. The problem was that the `periodicStatusUpdater` was being stopped to perform the parameter upload. But not re-started. I added a function to resume the updater, and everything works as it should. I made a few other changes:
- Tidied up the setting of the parameters for each profile
- Added specific `set` profile messages, rather than `loaded` being repeated
- Only show messages for the profiles that have changed, not all of them
This commit is contained in:
Mr D - RC 2024-09-21 10:11:22 +01:00
parent 45e7e41b96
commit c0e02494f6
7 changed files with 60 additions and 64 deletions

View file

@ -163,6 +163,7 @@ var defaultsDialog = (function () {
};
privateScope.reboot = function () {
periodicStatusUpdater.resume();
GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
@ -177,7 +178,6 @@ var defaultsDialog = (function () {
};
privateScope.finalize = function (selectedDefaultPreset) {
if (selectedDefaultPreset.wizardPages) {
privateScope.wizard(selectedDefaultPreset, 0);
} else {
@ -221,60 +221,26 @@ var defaultsDialog = (function () {
});
});
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [0], false, callback);
});
controlProfileSettings.forEach(input => {
// Set control and battery parameters on all 3 profiles
for (let profileIdx = 0; profileIdx < 3; profileIdx++){
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [profileIdx], false, callback);
});
controlProfileSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
});
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [1], false, callback);
});
controlProfileSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [profileIdx], false, callback);
});
});
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [2], false, callback);
});
controlProfileSettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
});
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [0], false, callback);
});
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [1], false, callback);
});
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
chain.push(function (callback) {
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [2], false, callback);
});
batterySettings.forEach(input => {
chain.push(function (callback) {
mspHelper.setSetting(input.key, input.value, callback);
});
});
}
// Set Mixers
if (selectedDefaultPreset.mixerToApply) {