mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-13 19:40:22 +03:00
Set specific defaults on all profiles
This commit is contained in:
parent
4f2fbb2c71
commit
7afbc5c97c
1 changed files with 51 additions and 10 deletions
|
@ -404,7 +404,7 @@ helper.defaultsDialog = (function () {
|
|||
{
|
||||
"title": 'Airplane without a Tail (Wing, Delta, etc)',
|
||||
"notRecommended": false,
|
||||
"id": 3,
|
||||
"id": 4,
|
||||
"reboot": true,
|
||||
"mixerToApply": 8,
|
||||
"settings": [
|
||||
|
@ -418,7 +418,7 @@ helper.defaultsDialog = (function () {
|
|||
},
|
||||
{
|
||||
key: "applied_defaults",
|
||||
value: 3
|
||||
value: 4
|
||||
},
|
||||
{
|
||||
key: "gyro_hardware_lpf",
|
||||
|
@ -718,7 +718,9 @@ helper.defaultsDialog = (function () {
|
|||
GUI.tab_switch_cleanup(function () {
|
||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
|
||||
//noinspection JSUnresolvedVariable
|
||||
if (typeof savingDefaultsModal !== 'undefined') {
|
||||
savingDefaultsModal.close();
|
||||
}
|
||||
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||
GUI.handleReconnect();
|
||||
});
|
||||
|
@ -728,13 +730,21 @@ helper.defaultsDialog = (function () {
|
|||
};
|
||||
|
||||
privateScope.setSettings = function (selectedDefaultPreset) {
|
||||
var currentControlProfile = parseInt($("#profilechange").val());
|
||||
var currentBatteryProfile = parseInt($("#batteryprofilechange").val());
|
||||
//Save analytics
|
||||
googleAnalytics.sendEvent('Setting', 'Defaults', selectedDefaultPreset.title);
|
||||
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||
return mspHelper.getSetting(input.key);
|
||||
}).then(function () {
|
||||
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||
if (FC.isControlProfileParameter(input.key)) {
|
||||
return privateScope.setSettingForAllControlProfiles(input.key, input.value);
|
||||
} else if (FC.isBatteryProfileParameter(input.key)) {
|
||||
return privateScope.setSettingForAllBatteryProfiles(input.key, input.value);
|
||||
} else {
|
||||
return mspHelper.setSetting(input.key, input.value);
|
||||
}
|
||||
}).then(function () {
|
||||
|
||||
// If default preset is associated to a mixer, apply the mixer as well
|
||||
|
@ -751,19 +761,50 @@ helper.defaultsDialog = (function () {
|
|||
|
||||
mspHelper.sendServoMixer(function () {
|
||||
mspHelper.sendMotorMixer(function () {
|
||||
privateScope.finalize(selectedDefaultPreset);
|
||||
})
|
||||
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [currentControlProfile], false, function() {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, privateScope.finalize(selectedDefaultPreset));
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
privateScope.finalize(selectedDefaultPreset);
|
||||
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [currentControlProfile], false, function() {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [currentBatteryProfile], false, privateScope.finalize(selectedDefaultPreset));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
privateScope.setSettingForAllControlProfiles = function (key, value) {
|
||||
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [0], false, function () {
|
||||
mspHelper.setSetting(key, value, function() {
|
||||
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [1], false, function () {
|
||||
mspHelper.setSetting(key, value, function() {
|
||||
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [2], false, function () {
|
||||
mspHelper.setSetting(key, value);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
privateScope.setSettingForAllBatteryProfiles = function (key, value) {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [0], false, function () {
|
||||
mspHelper.setSetting(key, value, function() {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [1], false, function () {
|
||||
mspHelper.setSetting(key, value, function() {
|
||||
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [2], false, function () {
|
||||
mspHelper.setSetting(key, value);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return;
|
||||
};
|
||||
|
||||
privateScope.onPresetClick = function (event) {
|
||||
savingDefaultsModal = new jBox('Modal', {
|
||||
width: 400,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue