dual set of defaults for PIDs: FW and MR

pull/124/head
Pawel Spychalski (DzikuVx) 8 years ago
parent 6e5d25d104
commit ec7f46f108

@ -417,6 +417,7 @@ var mspHelper = (function (gui) {
BF_CONFIG.currentoffset = data.getUint16(14, true);
break;
case MSPCodes.MSP_SET_BF_CONFIG:
console.log('BF_CONFIG saved');
break;
case MSPCodes.MSP_SET_REBOOT:
console.log('Reboot request accepted');

@ -11,7 +11,8 @@ presets.elementHelper = function (group, field, value) {
};
presets.defaultValues = {
PIDs: [
PIDs: {
mr: [
[40, 30, 23],
[40, 30, 23],
[85, 45, 0],
@ -23,6 +24,18 @@ presets.defaultValues = {
[60, 0, 0],
[100, 50, 10]
],
fw: [
[25, 35, 10],
[20, 35, 10],
[50, 45, 0],
[50, 0, 0],
[75, 5, 8],
[0, 0, 0],
[0, 0, 0],
[20, 15, 75],
[60, 0, 0],
[0, 0, 0]
]},
INAV_PID_CONFIG: {"asynchronousMode": "0", "accelerometerTaskFrequency": 500, "attitudeTaskFrequency": 250, "magHoldRateLimit": 90, "magHoldErrorLpfFrequency": 2, "yawJumpPreventionLimit": 200, "gyroscopeLpf": "3", "accSoftLpfHz": 15},
ADVANCED_CONFIG: {"gyroSyncDenominator": 2, "pidProcessDenom": 1, "useUnsyncedPwm": 1, "motorPwmProtocol": 0, "motorPwmRate": 400, "servoPwmRate": 50, "gyroSync": 0},
RC_tuning: {"RC_RATE": 1, "RC_EXPO": 0.7, "roll_pitch_rate": 0, "roll_rate": 200, "pitch_rate": 200, "yaw_rate": 200, "dynamic_THR_PID": 0, "throttle_MID": 0.5, "throttle_EXPO": 0, "dynamic_THR_breakpoint": 1500, "RC_YAW_EXPO": 0.2},
@ -37,6 +50,15 @@ presets.defaultValues = {
* BF_CONFIG::mixerConfiguration
*
*/
/**
* When defining a preset, following fields are required:
*
* BF_CONFIG::mixerConfiguration
*
* @type {{name: string, description: string, features: string[], applyDefaults: string[], settings: *[], type: string}[]}
*/
presets.presets = [
{
name: 'Default Preset',
@ -219,14 +241,25 @@ presets.model = (function () {
/**
* @param {Array} toApply
* @param {Object} defaults
* @param {String} mixerType
*/
self.applyDefaults = function (toApply, defaults) {
self.applyDefaults = function (toApply, defaults, mixerType) {
for (var settingToApply in toApply) {
if (toApply.hasOwnProperty(settingToApply)) {
var settingName = toApply[settingToApply],
values;
if (settingName == 'PIDs') {
if (mixerType == 'multirotor') {
values = defaults[settingName]['mr'];
} else {
values = defaults[settingName]['fw'];
}
} else {
values = defaults[settingName];
}
for (var key in values) {
if (values.hasOwnProperty(key)) {
@ -282,6 +315,7 @@ TABS.profiles.initialize = function (callback, scrollPosition) {
loadChainer.execute();
saveChainer.setChain([
mspHelper.saveBfConfig,
mspHelper.saveINAVPidConfig,
mspHelper.saveLooptimeConfig,
mspHelper.saveAdvancedConfig,
@ -289,7 +323,6 @@ TABS.profiles.initialize = function (callback, scrollPosition) {
mspHelper.savePidData,
mspHelper.saveRcTuningData,
mspHelper.savePidAdvanced,
mspHelper.saveBfConfig,
mspHelper.saveToEeprom
]);
saveChainer.setExitPoint(reboot);
@ -314,7 +347,7 @@ TABS.profiles.initialize = function (callback, scrollPosition) {
function applyAndSave() {
presets.model.applyDefaults(currentPreset.applyDefaults, presets.defaultValues);
presets.model.applyDefaults(currentPreset.applyDefaults, presets.defaultValues, currentPreset.type);
var setting;

Loading…
Cancel
Save