mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 21:05:28 +03:00
Merge pull request #1605 from iNavFlight/MrD_Set-platform-defaults-on-all-profiles
Set specific defaults (defaults dialog) on all profiles
This commit is contained in:
commit
1f8b2bcbb2
1 changed files with 51 additions and 10 deletions
|
@ -432,7 +432,7 @@ helper.defaultsDialog = (function () {
|
||||||
{
|
{
|
||||||
"title": 'Airplane without a Tail (Wing, Delta, etc)',
|
"title": 'Airplane without a Tail (Wing, Delta, etc)',
|
||||||
"notRecommended": false,
|
"notRecommended": false,
|
||||||
"id": 3,
|
"id": 4,
|
||||||
"reboot": true,
|
"reboot": true,
|
||||||
"mixerToApply": 8,
|
"mixerToApply": 8,
|
||||||
"settings": [
|
"settings": [
|
||||||
|
@ -446,7 +446,7 @@ helper.defaultsDialog = (function () {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "applied_defaults",
|
key: "applied_defaults",
|
||||||
value: 3
|
value: 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "gyro_hardware_lpf",
|
key: "gyro_hardware_lpf",
|
||||||
|
@ -774,7 +774,9 @@ helper.defaultsDialog = (function () {
|
||||||
GUI.tab_switch_cleanup(function () {
|
GUI.tab_switch_cleanup(function () {
|
||||||
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
|
||||||
//noinspection JSUnresolvedVariable
|
//noinspection JSUnresolvedVariable
|
||||||
|
if (typeof savingDefaultsModal !== 'undefined') {
|
||||||
savingDefaultsModal.close();
|
savingDefaultsModal.close();
|
||||||
|
}
|
||||||
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||||
GUI.handleReconnect();
|
GUI.handleReconnect();
|
||||||
});
|
});
|
||||||
|
@ -784,13 +786,21 @@ helper.defaultsDialog = (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
privateScope.setSettings = function (selectedDefaultPreset) {
|
privateScope.setSettings = function (selectedDefaultPreset) {
|
||||||
|
var currentControlProfile = parseInt($("#profilechange").val());
|
||||||
|
var currentBatteryProfile = parseInt($("#batteryprofilechange").val());
|
||||||
//Save analytics
|
//Save analytics
|
||||||
googleAnalytics.sendEvent('Setting', 'Defaults', selectedDefaultPreset.title);
|
googleAnalytics.sendEvent('Setting', 'Defaults', selectedDefaultPreset.title);
|
||||||
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
||||||
return mspHelper.getSetting(input.key);
|
return mspHelper.getSetting(input.key);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
Promise.mapSeries(selectedDefaultPreset.settings, function (input, ii) {
|
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);
|
return mspHelper.setSetting(input.key, input.value);
|
||||||
|
}
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
|
|
||||||
// If default preset is associated to a mixer, apply the mixer as well
|
// If default preset is associated to a mixer, apply the mixer as well
|
||||||
|
@ -807,19 +817,50 @@ helper.defaultsDialog = (function () {
|
||||||
|
|
||||||
mspHelper.sendServoMixer(function () {
|
mspHelper.sendServoMixer(function () {
|
||||||
mspHelper.sendMotorMixer(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 {
|
} 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) {
|
privateScope.onPresetClick = function (event) {
|
||||||
savingDefaultsModal = new jBox('Modal', {
|
savingDefaultsModal = new jBox('Modal', {
|
||||||
width: 400,
|
width: 400,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue