From d0ae05d17e1ca84069fafe95ba64f1e69321124f Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 11 May 2020 12:34:49 +0200 Subject: [PATCH 1/2] Simplify Preset handling --- js/preset_definitions.js | 162 ++++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 72 deletions(-) diff --git a/js/preset_definitions.js b/js/preset_definitions.js index 662d79b8..5149d047 100644 --- a/js/preset_definitions.js +++ b/js/preset_definitions.js @@ -37,17 +37,9 @@ presets.defaultValues = { [0, 0, 0, 0] //PID_VEL_Z ]}, 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": 1}, 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}, PID_ADVANCED: {"rollPitchItermIgnoreRate": 200, "yawItermIgnoreRate": 50, "yawPLimit": 300, "axisAccelerationLimitRollPitch": 0, "axisAccelerationLimitYaw": 1000}, - FILTER_CONFIG: {"gyroSoftLpfHz": 60, "dtermLpfHz": 40, "yawLpfHz": 30, "gyroNotchHz1": 0, "gyroNotchCutoff1": 0, "dtermNotchHz": 0, "dtermNotchCutoff": 0, "gyroNotchHz2": 0, "gyroNotchCutoff2": 0, "accNotchHz": 0, "accNotchCutoff": 0, "gyroStage2LowpassHz": 0}, - FC_CONFIG: {"loopTime": 1000}, - MIXER_CONFIG: { - "yawMotorDirection": 1, - "yawJumpPreventionLimit": 200, - "platformType": 0, - "hasFlaps": false - } + FILTER_CONFIG: {"gyroSoftLpfHz": 60, "dtermLpfHz": 40, "yawLpfHz": 30, "gyroNotchHz1": 0, "gyroNotchCutoff1": 0, "dtermNotchHz": 0, "dtermNotchCutoff": 0, "gyroNotchHz2": 0, "gyroNotchCutoff2": 0, "accNotchHz": 0, "accNotchCutoff": 0, "gyroStage2LowpassHz": 0} }; presets.settings = { @@ -72,11 +64,6 @@ presets.settings = { } /** - * When defining a preset, following fields are required: - * - * BF_CONFIG::mixerConfiguration - * MIXER_CONFIG::platformType - * * @type {{name: string, description: string, features: string[], applyDefaults: string[], settingsMSP: *[], type: string}[]} */ presets.presets = [ @@ -84,12 +71,13 @@ presets.presets = [ name: '3-inch Multirotor Preset', description: "INAV Quad X configuration, 3-inch propellers. F4/F7 CPU.", features: ["DSHOT600", "4k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], - settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 3), - presets.elementHelper("MIXER_CONFIG", "platformType", 0) - ], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + settingsMSP: [], settings: [ + { + key: "platform_type", + value: "MULTIROTOR" + }, { key: "motor_pwm_protocol", value: "DSHOT600" @@ -253,12 +241,13 @@ presets.presets = [ name: 'MegaBee Cinewoop', description: "iFlight MegaBee Preset", features: ["DSHOT600", "4k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], - settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 3), - presets.elementHelper("MIXER_CONFIG", "platformType", 0) - ], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + settingsMSP: [], settings: [ + { + key: "platform_type", + value: "MULTIROTOR" + }, { key: "motor_pwm_protocol", value: "DSHOT600" @@ -430,12 +419,13 @@ presets.presets = [ name: '5-inch Multirotor Preset', description: "INAV Quad X configuration, 5-inch propellers. F4/F7 CPU. GPS and Magnetometer are optional", features: ["DSHOT600", "2k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], - settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 3), - presets.elementHelper("MIXER_CONFIG", "platformType", 0) - ], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + settingsMSP: [], settings: [ + { + key: "platform_type", + value: "MULTIROTOR" + }, { key: "motor_pwm_protocol", value: "DSHOT600" @@ -546,7 +536,7 @@ presets.presets = [ }, { key: "mc_d_roll", - value: 25 + value: 23 }, { key: "mc_p_yaw", @@ -591,12 +581,13 @@ presets.presets = [ name: '5-inch, 2208 2450KV motors', description: "Overpowered freestyle kwad. 5-inch, 3 bladed propellers like HQProp S4, Nepal N1, 2208 2450KV motors, 4S, DSHOT600 ESC protocol. Optimized for smooth, freestyle or acrobatic flight.", features: ["DSHOT600", "4k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], - settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 3), - presets.elementHelper("MIXER_CONFIG", "platformType", 0) - ], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + settingsMSP: [], settings: [ + { + key: "platform_type", + value: "MULTIROTOR" + }, { key: "motor_pwm_protocol", value: "DSHOT600" @@ -619,7 +610,7 @@ presets.presets = [ }, { key: "gyro_stage2_lowpass_hz", - value: 250 + value: 0 }, { key: "gyro_stage2_lowpass_type", @@ -635,7 +626,7 @@ presets.presets = [ }, { key: "dterm_lpf2_hz", - value: 250 + value: 170 }, { key: "dterm_lpf2_type", @@ -703,7 +694,7 @@ presets.presets = [ }, { key: "mc_d_pitch", - value: 30 + value: 28 }, { key: "mc_p_roll", @@ -715,7 +706,7 @@ presets.presets = [ }, { key: "mc_d_roll", - value: 26 + value: 24 }, { key: "mc_p_yaw", @@ -760,12 +751,13 @@ presets.presets = [ name: '6-inch, 2207 1700KV motors', description: "6-inch, 3 bladed propellers, 2207 1700KV motors, 4S, DSHOT600 ESC protocol. Optimized for smooth, freestyle or acrobatic flight with GPS or not.", features: ["DSHOT600", "2k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], - settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 3), - presets.elementHelper("MIXER_CONFIG", "platformType", 0) - ], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + settingsMSP: [], settings: [ + { + key: "platform_type", + value: "MULTIROTOR" + }, { key: "motor_pwm_protocol", value: "DSHOT600" @@ -929,12 +921,13 @@ presets.presets = [ name: '7-inch Multirotor Preset', description: "General configuration for 7-inch propellers. Adjusted rates and filtering.", features: ["DSHOT600", "2k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], - settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 3), - presets.elementHelper("MIXER_CONFIG", "platformType", 0) - ], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + settingsMSP: [], settings: [ + { + key: "platform_type", + value: "MULTIROTOR" + }, { key: "motor_pwm_protocol", value: "DSHOT600" @@ -1103,12 +1096,13 @@ presets.presets = [ "Improved PID defaults", "Adjusted filtering" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], - settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 3), - presets.elementHelper("MIXER_CONFIG", "platformType", 0) - ], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + settingsMSP: [], settings: [ + { + key: "platform_type", + value: "MULTIROTOR" + }, { key: "motor_pwm_protocol", value: "DSHOT600" @@ -1280,15 +1274,19 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 14), - presets.elementHelper("MIXER_CONFIG", "platformType", 1), presets.elementHelper("RC_tuning", "roll_rate", 200), presets.elementHelper("RC_tuning", "pitch_rate", 150), presets.elementHelper("RC_tuning", "yaw_rate", 90), presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 1) ], + settings: [ + { + key: "platform_type", + value: "AIRPLANE" + } + ], type: 'airplane' }, { @@ -1300,10 +1298,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 8), - presets.elementHelper("MIXER_CONFIG", "platformType", 1), presets.elementHelper("PIDs", 0, [2, 15, 0, 30]), //ROLL PIDs presets.elementHelper("PIDs", 1, [2, 15, 0, 70]), //PITCH PIDs presets.elementHelper("PIDs", 7, [10, 15, 75, 0]), //LEVEL PIDs @@ -1313,6 +1309,12 @@ presets.presets = [ presets.elementHelper("RC_tuning", "dynamic_THR_breakpoint", 1300), presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 4) ], + settings: [ + { + key: "platform_type", + value: "AIRPLANE" + } + ], type: 'flyingwing' }, { @@ -1323,10 +1325,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 8), - presets.elementHelper("MIXER_CONFIG", "platformType", 1), presets.elementHelper("PIDs", 0, [6, 6, 0, 49]), //ROLL PIDs presets.elementHelper("PIDs", 1, [6, 9, 0, 52]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), @@ -1336,6 +1336,12 @@ presets.presets = [ presets.elementHelper("RC_tuning", "dynamic_THR_PID", 20), presets.elementHelper("RC_tuning", "dynamic_THR_breakpoint", 1600) ], + settings: [ + { + key: "platform_type", + value: "AIRPLANE" + } + ], type: 'flyingwing' }, { @@ -1346,10 +1352,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 8), - presets.elementHelper("MIXER_CONFIG", "platformType", 1), presets.elementHelper("PIDs", 0, [7, 7, 0, 25]), //ROLL PIDs presets.elementHelper("PIDs", 1, [5, 9, 0, 56]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), @@ -1359,6 +1363,12 @@ presets.presets = [ presets.elementHelper("RC_tuning", "dynamic_THR_PID", 30), presets.elementHelper("RC_tuning", "dynamic_THR_breakpoint", 1550) ], + settings: [ + { + key: "platform_type", + value: "AIRPLANE" + } + ], type: 'flyingwing' }, { @@ -1369,10 +1379,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 8), - presets.elementHelper("MIXER_CONFIG", "platformType", 1), presets.elementHelper("PIDs", 0, [9, 12, 0, 15]), //ROLL PIDs presets.elementHelper("PIDs", 1, [9, 15, 0, 14]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), @@ -1382,6 +1390,12 @@ presets.presets = [ presets.elementHelper("RC_tuning", "dynamic_THR_PID", 30), presets.elementHelper("RC_tuning", "dynamic_THR_breakpoint", 1500) ], + settings: [ + { + key: "platform_type", + value: "AIRPLANE" + } + ], type: 'flyingwing' }, { @@ -1392,10 +1406,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "ADVANCED_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG", "FC_CONFIG", "MIXER_CONFIG"], + applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("BF_CONFIG", "mixerConfiguration", 8), - presets.elementHelper("MIXER_CONFIG", "platformType", 1), presets.elementHelper("PIDs", 0, [8, 16, 0, 64]), //ROLL PIDs presets.elementHelper("PIDs", 1, [5, 18, 0, 60]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), @@ -1403,6 +1415,12 @@ presets.presets = [ presets.elementHelper("RC_tuning", "roll_rate", 280), presets.elementHelper("RC_tuning", "pitch_rate", 120) ], + settings: [ + { + key: "platform_type", + value: "AIRPLANE" + } + ], type: 'flyingwing' } ]; \ No newline at end of file From 8ae3f1ccdca4f983de8628cce0fb2d7587380653 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Mon, 11 May 2020 14:18:23 +0200 Subject: [PATCH 2/2] Drop dependency of PIDs MSP frame --- js/preset_definitions.js | 182 ++++++++++++++++++++++++++++----------- tabs/profiles.js | 47 ++++------ 2 files changed, 152 insertions(+), 77 deletions(-) diff --git a/js/preset_definitions.js b/js/preset_definitions.js index 5149d047..a03d3b33 100644 --- a/js/preset_definitions.js +++ b/js/preset_definitions.js @@ -11,31 +11,6 @@ presets.elementHelper = function (group, field, value) { }; presets.defaultValues = { - PIDs: { - mr: [ - [40, 30, 23, 0], //PID_ROLL - [40, 30, 23, 0], //PID_PITCH - [85, 45, 0, 0], //PID_YAW - [50, 0, 0, 0], //PID_POS_Z - [65, 120, 10, 0], //PID_POS_XY - [40, 15, 100, 40], //PID_VEL_XY - [0, 0, 0, 0], //PID_SURFACE - [20, 15, 75, 0], //PID_LEVEL - [60, 0, 0, 0], //PID_HEADING - [100, 50, 10, 0] //PID_VEL_Z - ], - fw: [ - [5, 7, 0, 50], //PID_ROLL - [5, 7, 0, 50], //PID_PITCH - [6, 10, 0, 60], //PID_YAW - [40, 5, 10, 0], //PID_POS_Z - [75, 5, 8, 0], //PID_POS_XY - [0, 0, 0, 0], //PID_VEL_XY - [0, 0, 0, 0], //PID_SURFACE - [20, 5, 75, 0], //PID_LEVEL - [60, 0, 0, 0], //PID_HEADING - [0, 0, 0, 0] //PID_VEL_Z - ]}, INAV_PID_CONFIG: {"asynchronousMode": "0", "accelerometerTaskFrequency": 500, "attitudeTaskFrequency": 250, "magHoldRateLimit": 90, "magHoldErrorLpfFrequency": 2, "yawJumpPreventionLimit": 200, "gyroscopeLpf": "3", "accSoftLpfHz": 15}, 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}, PID_ADVANCED: {"rollPitchItermIgnoreRate": 200, "yawItermIgnoreRate": 50, "yawPLimit": 300, "axisAccelerationLimitRollPitch": 0, "axisAccelerationLimitYaw": 1000}, @@ -71,7 +46,7 @@ presets.presets = [ name: '3-inch Multirotor Preset', description: "INAV Quad X configuration, 3-inch propellers. F4/F7 CPU.", features: ["DSHOT600", "4k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [], settings: [ { @@ -241,7 +216,7 @@ presets.presets = [ name: 'MegaBee Cinewoop', description: "iFlight MegaBee Preset", features: ["DSHOT600", "4k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [], settings: [ { @@ -419,7 +394,7 @@ presets.presets = [ name: '5-inch Multirotor Preset', description: "INAV Quad X configuration, 5-inch propellers. F4/F7 CPU. GPS and Magnetometer are optional", features: ["DSHOT600", "2k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [], settings: [ { @@ -581,7 +556,7 @@ presets.presets = [ name: '5-inch, 2208 2450KV motors', description: "Overpowered freestyle kwad. 5-inch, 3 bladed propellers like HQProp S4, Nepal N1, 2208 2450KV motors, 4S, DSHOT600 ESC protocol. Optimized for smooth, freestyle or acrobatic flight.", features: ["DSHOT600", "4k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [], settings: [ { @@ -751,7 +726,7 @@ presets.presets = [ name: '6-inch, 2207 1700KV motors', description: "6-inch, 3 bladed propellers, 2207 1700KV motors, 4S, DSHOT600 ESC protocol. Optimized for smooth, freestyle or acrobatic flight with GPS or not.", features: ["DSHOT600", "2k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [], settings: [ { @@ -921,7 +896,7 @@ presets.presets = [ name: '7-inch Multirotor Preset', description: "General configuration for 7-inch propellers. Adjusted rates and filtering.", features: ["DSHOT600", "2k mode", "Matrix Filter", "Improved mechanics", "Optimized filtering", "Optimized rates"], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [], settings: [ { @@ -1096,7 +1071,7 @@ presets.presets = [ "Improved PID defaults", "Adjusted filtering" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [], settings: [ { @@ -1274,7 +1249,7 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ presets.elementHelper("RC_tuning", "roll_rate", 200), presets.elementHelper("RC_tuning", "pitch_rate", 150), @@ -1298,11 +1273,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("PIDs", 0, [2, 15, 0, 30]), //ROLL PIDs - presets.elementHelper("PIDs", 1, [2, 15, 0, 70]), //PITCH PIDs - presets.elementHelper("PIDs", 7, [10, 15, 75, 0]), //LEVEL PIDs presets.elementHelper("RC_tuning", "roll_rate", 350), presets.elementHelper("RC_tuning", "pitch_rate", 90), presets.elementHelper("RC_tuning", "dynamic_THR_PID", 33), @@ -1313,6 +1285,30 @@ presets.presets = [ { key: "platform_type", value: "AIRPLANE" + }, + { + key: "fw_p_pitch", + value: 2 + }, + { + key: "fw_i_pitch", + value: 15 + }, + { + key: "fw_ff_pitch", + value: 70 + }, + { + key: "fw_p_roll", + value: 2 + }, + { + key: "fw_i_roll", + value: 15 + }, + { + key: "fw_ff_roll", + value: 30 } ], type: 'flyingwing' @@ -1325,10 +1321,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("PIDs", 0, [6, 6, 0, 49]), //ROLL PIDs - presets.elementHelper("PIDs", 1, [6, 9, 0, 52]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), presets.elementHelper("FILTER_CONFIG", "gyroSoftLpfHz", 40), presets.elementHelper("RC_tuning", "roll_rate", 280), @@ -1340,6 +1334,30 @@ presets.presets = [ { key: "platform_type", value: "AIRPLANE" + }, + { + key: "fw_p_pitch", + value: 6 + }, + { + key: "fw_i_pitch", + value: 9 + }, + { + key: "fw_ff_pitch", + value: 52 + }, + { + key: "fw_p_roll", + value: 6 + }, + { + key: "fw_i_roll", + value: 6 + }, + { + key: "fw_ff_roll", + value: 49 } ], type: 'flyingwing' @@ -1352,10 +1370,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("PIDs", 0, [7, 7, 0, 25]), //ROLL PIDs - presets.elementHelper("PIDs", 1, [5, 9, 0, 56]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), presets.elementHelper("FILTER_CONFIG", "gyroSoftLpfHz", 35), presets.elementHelper("RC_tuning", "roll_rate", 260), @@ -1367,6 +1383,30 @@ presets.presets = [ { key: "platform_type", value: "AIRPLANE" + }, + { + key: "fw_p_pitch", + value: 5 + }, + { + key: "fw_i_pitch", + value: 14 + }, + { + key: "fw_ff_pitch", + value: 56 + }, + { + key: "fw_p_roll", + value: 7 + }, + { + key: "fw_i_roll", + value: 12 + }, + { + key: "fw_ff_roll", + value: 25 } ], type: 'flyingwing' @@ -1379,10 +1419,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("PIDs", 0, [9, 12, 0, 15]), //ROLL PIDs - presets.elementHelper("PIDs", 1, [9, 15, 0, 14]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), presets.elementHelper("FILTER_CONFIG", "gyroSoftLpfHz", 35), presets.elementHelper("RC_tuning", "roll_rate", 360), @@ -1394,6 +1432,30 @@ presets.presets = [ { key: "platform_type", value: "AIRPLANE" + }, + { + key: "fw_p_pitch", + value: 9 + }, + { + key: "fw_i_pitch", + value: 15 + }, + { + key: "fw_ff_pitch", + value: 14 + }, + { + key: "fw_p_roll", + value: 9 + }, + { + key: "fw_i_roll", + value: 12 + }, + { + key: "fw_ff_roll", + value: 15 } ], type: 'flyingwing' @@ -1406,10 +1468,8 @@ presets.presets = [ "Adjusted PIDs", "Adjusted rates" ], - applyDefaults: ["PIDs", "INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], + applyDefaults: ["INAV_PID_CONFIG", "RC_tuning", "PID_ADVANCED", "FILTER_CONFIG"], settingsMSP: [ - presets.elementHelper("PIDs", 0, [8, 16, 0, 64]), //ROLL PIDs - presets.elementHelper("PIDs", 1, [5, 18, 0, 60]), //PITCH PIDs presets.elementHelper("INAV_PID_CONFIG", "gyroscopeLpf", 0), presets.elementHelper("FILTER_CONFIG", "gyroSoftLpfHz", 35), presets.elementHelper("RC_tuning", "roll_rate", 280), @@ -1419,6 +1479,30 @@ presets.presets = [ { key: "platform_type", value: "AIRPLANE" + }, + { + key: "fw_p_pitch", + value: 5 + }, + { + key: "fw_i_pitch", + value: 18 + }, + { + key: "fw_ff_pitch", + value: 60 + }, + { + key: "fw_p_roll", + value: 8 + }, + { + key: "fw_i_roll", + value: 16 + }, + { + key: "fw_ff_roll", + value: 64 } ], type: 'flyingwing' diff --git a/tabs/profiles.js b/tabs/profiles.js index bb103e02..8682dbad 100644 --- a/tabs/profiles.js +++ b/tabs/profiles.js @@ -17,24 +17,13 @@ presets.model = (function () { 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)) { window[settingName][key] = values[key]; } } - } } if (mixerType == 'airplane' || mixerType == 'flyingwing') { @@ -106,27 +95,29 @@ TABS.profiles.initialize = function (callback, scrollPosition) { } function applySettings() { - Promise.mapSeries(currentPreset.settings, function (input, ii) { - return mspHelper.getSetting(input.key); - }).then(function () { + if (currentPreset.settings && currentPreset.settings.length > 0) { Promise.mapSeries(currentPreset.settings, function (input, ii) { - console.log('applying', input.key, input.value); - return mspHelper.setSetting(input.key, input.value); + return mspHelper.getSetting(input.key); }).then(function () { - mspHelper.saveToEeprom(function () { - //noinspection JSUnresolvedVariable - GUI.log(chrome.i18n.getMessage('configurationEepromSaved')); - - GUI.tab_switch_cleanup(function() { - MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { - //noinspection JSUnresolvedVariable - GUI.log(chrome.i18n.getMessage('deviceRebooting')); - GUI.handleReconnect(); + Promise.mapSeries(currentPreset.settings, function (input, ii) { + console.log('applying', input.key, input.value); + return mspHelper.setSetting(input.key, input.value); + }).then(function () { + mspHelper.saveToEeprom(function () { + //noinspection JSUnresolvedVariable + GUI.log(chrome.i18n.getMessage('configurationEepromSaved')); + + GUI.tab_switch_cleanup(function() { + MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { + //noinspection JSUnresolvedVariable + GUI.log(chrome.i18n.getMessage('deviceRebooting')); + GUI.handleReconnect(); + }); }); }); - }); - }) - }); + }) + }); + } } function applyAndSave() {