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)',
|
"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": [
|
||||||
|
@ -418,7 +418,7 @@ helper.defaultsDialog = (function () {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "applied_defaults",
|
key: "applied_defaults",
|
||||||
value: 3
|
value: 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "gyro_hardware_lpf",
|
key: "gyro_hardware_lpf",
|
||||||
|
@ -718,7 +718,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
|
||||||
savingDefaultsModal.close();
|
if (typeof savingDefaultsModal !== 'undefined') {
|
||||||
|
savingDefaultsModal.close();
|
||||||
|
}
|
||||||
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
GUI.log(chrome.i18n.getMessage('deviceRebooting'));
|
||||||
GUI.handleReconnect();
|
GUI.handleReconnect();
|
||||||
});
|
});
|
||||||
|
@ -728,13 +730,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) {
|
||||||
return mspHelper.setSetting(input.key, input.value);
|
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 () {
|
}).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
|
||||||
|
@ -751,19 +761,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