diff --git a/locale/en/messages.json b/locale/en/messages.json index bd3ff5756..c5e53172e 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -1325,6 +1325,24 @@ "portsFunction_SBUS_OUTPUT": { "message": "SBus Output" }, + "pidTuning_Other": { + "message": "Other" + }, + "pidTuning_Limits": { + "message": "Limits" + }, + "pidTuning_HeadingHold_Rate": { + "message": "Heading Hold Rate (°/s)" + }, + "pidTuning_Max_Inclination_Angle": { + "message": "Max Inclination Angle" + }, + "pidTuning_Max_Roll": { + "message": "Roll (°/10)" + }, + "pidTuning_Max_Pitch": { + "message": "Pitch (°/10)" + }, "pidTuning_ShowAllPIDs": { "message": "Show all PIDs" }, @@ -1391,6 +1409,30 @@ "pidTuning_RatesAndExpo": { "message": "Rates & Expo" }, + "pidTuning_Rates_Stabilized": { + "message": "Stabilized Rates" + }, + "pidTuning_Rates_Roll": { + "message": "Roll (°/s)" + }, + "pidTuning_Rates_Pitch": { + "message": "Pitch (°/s)" + }, + "pidTuning_Rates_Yaw": { + "message": "Yaw (°/s)" + }, + "pidTuning_Expo_Stabilized": { + "message": "Stabilized Expo" + }, + "pidTuning_Expo_Manual": { + "message": "Manual Expo" + }, + "pidTuning_Expo_RollPitch": { + "message": "Roll & Pitch (%)" + }, + "pidTuning_Expo_Yaw": { + "message": "Yaw (%)" + }, "pidTuning_RateDynamics": { "message": "Rate Dynamics" }, @@ -1592,6 +1634,18 @@ "pidTuning_LoadedProfile": { "message": "Loaded Profile: $1" }, + "pidTuning_Manual_Rates": { + "message": "Manual Rates" + }, + "pidTuning_Manual_Roll": { + "message": "Roll (%)" + }, + "pidTuning_Manual_Pitch": { + "message": "Pitch (%)" + }, + "pidTuning_Manual_Yaw": { + "message": "Yaw (%)" + }, "pidTuning_gyro_use_dyn_lpf": { "message": "Dynamic gyro LPF" }, diff --git a/src/css/tabs/pid_tuning.css b/src/css/tabs/pid_tuning.css index 1ebf20f8b..264cfb2bc 100644 --- a/src/css/tabs/pid_tuning.css +++ b/src/css/tabs/pid_tuning.css @@ -410,7 +410,7 @@ .pid-slider-row span, .pid-switch-row .label { margin-right: 2em; - width: 120px; + width: 150px; line-height: 22px;; } @@ -465,4 +465,15 @@ #pid-sliders { margin-bottom: 1em; +} + +.tab-pid_tuning .expo-chart { + margin: 0 0px 0px 0; + width: 200px; + height: 117px; + border: 1px solid silver; + border-radius: 3px; + background-image: url(./../../../images/paper.jpg); + background-size: 200%; + background-position: center; } \ No newline at end of file diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index f982e2f8e..9da4d855a 100644 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -185,6 +185,11 @@

+
+
+ +
+
@@ -436,82 +441,137 @@

-
+
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ +
+

+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+
+
+ +
+
+
+ +
+
+

+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+

+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+

+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+

+
+ +
+ +
+
+
+
+ +
+ +
+

+
+ +
+ +
+
+
+
+ +
+ +
+
+
diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index bae27211b..78efb95eb 100644 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -9,17 +9,15 @@ const mspHelper = require('./../js/msp/MSPHelper'); const MSPCodes = require('./../js/msp/MSPCodes'); const MSP = require('./../js/msp'); const { GUI, TABS } = require('./../js/gui'); -const features = require('./../js/feature_framework'); const tabs = require('./../js/tabs'); const FC = require('./../js/fc'); const Settings = require('./../js/settings'); const i18n = require('./../js/localization'); const { scaleRangeInt } = require('./../js/helpers'); -const SerialBackend = require('./../js/serial_backend'); -const BitHelper = require('./../js/bitHelper'); +const interval = require('./../js/intervals'); TABS.pid_tuning = { - + rateChartHeight: 117 }; TABS.pid_tuning.initialize = function (callback) { @@ -32,10 +30,10 @@ TABS.pid_tuning.initialize = function (callback) { var loadChain = [ mspHelper.loadPidData, mspHelper.loadRateDynamics, + mspHelper.loadRateProfileData, mspHelper.loadEzTune, mspHelper.loadMixerConfig, ]; - loadChain.push(mspHelper.loadRateProfileData); loadChainer.setChain(loadChain); loadChainer.setExitPoint(load_html); @@ -49,6 +47,75 @@ TABS.pid_tuning.initialize = function (callback) { GUI.load(path.join(__dirname, "pid_tuning.html"), Settings.processHtml(process_html)); } + function drawExpoCanvas(value, $element, color, width, height, clear) { + let context = $element.getContext("2d"); + + if (value < 0 || value > 1) { + return; + } + + if (clear === true) { + context.clearRect(0, 0, width, height); + } + + context.beginPath(); + context.moveTo(0, height); + context.quadraticCurveTo(width / 2, height - ((height / 2) * (1 - value)), width, 0); + context.lineWidth = 2; + context.strokeStyle = color; + context.stroke(); + + }; + + function drawRollPitchYawExpo() { + let pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); + let manual_expo_curve = $('.manual_expo_curve canvas').get(0); + + drawExpoCanvas( + parseFloat($('#rate_rollpitch_expo').val()) / 100, + pitch_roll_curve, + '#a00000', + 200, + TABS.pid_tuning.rateChartHeight, + true + ); + drawExpoCanvas( + parseFloat($('#rate_yaw_expo').val()) / 100, + pitch_roll_curve, + '#00a000', + 200, + TABS.pid_tuning.rateChartHeight, + false + ); + + drawExpoCanvas( + parseFloat($('#manual_rollpitch_expo').val()) / 100, + manual_expo_curve, + '#a00000', + 200, + TABS.pid_tuning.rateChartHeight, + true + ); + + drawExpoCanvas( + parseFloat($('#manual_yaw_expo').val()) / 100, + manual_expo_curve, + '#00a000', + 200, + TABS.pid_tuning.rateChartHeight, + false + ); + + drawExpoCanvas( + Math.floor(scaleRange($('#ez_tune_expo').val(), 0, 200, 40, 100)) / 100, + $('#ez_tune_expo_curve canvas').get(0), + '#a00000', + 250, + 200, + true + ); + } + function pid_and_rc_to_form() { // Fill in the data from FC.PIDs array @@ -67,15 +134,6 @@ TABS.pid_tuning.initialize = function (callback) { } }); - // Fill in data from FC.RC_tuning object - $('#rate-roll').val(FC.RC_tuning.roll_rate); - $('#rate-pitch').val(FC.RC_tuning.pitch_rate); - $('#rate-yaw').val(FC.RC_tuning.yaw_rate); - - $('#rate-manual-roll').val(FC.RC_tuning.manual_roll_rate); - $('#rate-manual-pitch').val(FC.RC_tuning.manual_pitch_rate); - $('#rate-manual-yaw').val(FC.RC_tuning.manual_yaw_rate); - $('#tpa').val(FC.RC_tuning.dynamic_THR_PID); $('#tpa-breakpoint').val(FC.RC_tuning.dynamic_THR_breakpoint); } @@ -98,17 +156,23 @@ TABS.pid_tuning.initialize = function (callback) { } }); - // catch FC.RC_tuning changes - FC.RC_tuning.roll_rate = parseFloat($('#rate-roll').val()); - FC.RC_tuning.pitch_rate = parseFloat($('#rate-pitch').val()); - FC.RC_tuning.yaw_rate = parseFloat($('#rate-yaw').val()); + // catch RC_tuning changes + FC.RC_tuning.roll_rate = parseFloat($('#rate_roll_rate').val()); + FC.RC_tuning.pitch_rate = parseFloat($('#rate_pitch_rate').val()); + FC.RC_tuning.yaw_rate = parseFloat($('#rate_yaw_rate').val()); + + FC.RC_tuning.RC_EXPO = parseFloat($('#rate_rollpitch_expo').val()) / 100; + FC.RC_tuning.RC_YAW_EXPO = parseFloat($('#rate_yaw_expo').val()) / 100; FC.RC_tuning.dynamic_THR_PID = parseInt($('#tpaRate').val()); FC.RC_tuning.dynamic_THR_breakpoint = parseInt($('#tpaBreakpoint').val()); - FC.RC_tuning.manual_roll_rate = $('#rate-manual-roll').val(); - FC.RC_tuning.manual_pitch_rate = $('#rate-manual-pitch').val(); - FC.RC_tuning.manual_yaw_rate = $('#rate-manual-yaw').val(); + FC.RC_tuning.manual_roll_rate = $('#rate_manual_roll').val(); + FC.RC_tuning.manual_pitch_rate = $('#rate_manual_pitch').val(); + FC.RC_tuning.manual_yaw_rate = $('#rate_manual_yaw').val(); + + FC.RC_tuning.manual_RC_EXPO = $('#manual_rollpitch_expo').val() / 100; + FC.RC_tuning.manual_RC_YAW_EXPO = $('#manual_yaw_expo').val() / 100; // Rate Dynamics FC.RATE_DYNAMICS.sensitivityCenter = parseInt($('#rate_dynamics_center_sensitivity').val()); @@ -189,6 +253,11 @@ TABS.pid_tuning.initialize = function (callback) { if (!FC.isMultirotor()) { $('#ez-tune-switch').hide(); + $('.only-for-multirotor').hide(); + } + + if (FC.isMultirotor()) { + $('.not-for-multirotor').hide(); } $("#ez_tune_enabled").prop('checked', FC.EZ_TUNE.enabled).trigger('change'); @@ -209,6 +278,21 @@ TABS.pid_tuning.initialize = function (callback) { updatePreview(); }); + //Slider rates + GUI.sliderize($('#rate_roll_rate'), FC.RC_tuning.roll_rate, 40, 1000); + GUI.sliderize($('#rate_pitch_rate'), FC.RC_tuning.pitch_rate, 40, 1000); + GUI.sliderize($('#rate_yaw_rate'), FC.RC_tuning.yaw_rate, 40, 1000); + + GUI.sliderize($('#rate_rollpitch_expo'), FC.RC_tuning.RC_EXPO * 100, 0, 100); + GUI.sliderize($('#rate_yaw_expo'), FC.RC_tuning.RC_YAW_EXPO * 100, 0, 100); + + GUI.sliderize($('#rate_manual_roll'), FC.RC_tuning.manual_roll_rate, 0, 100); + GUI.sliderize($('#rate_manual_pitch'), FC.RC_tuning.manual_pitch_rate, 0, 100); + GUI.sliderize($('#rate_manual_yaw'), FC.RC_tuning.manual_yaw_rate, 0, 100); + + GUI.sliderize($('#manual_rollpitch_expo'), FC.RC_tuning.manual_RC_EXPO * 100, 0, 100); + GUI.sliderize($('#manual_yaw_expo'), FC.RC_tuning.manual_RC_YAW_EXPO * 100, 0, 100); + updatePreview(); tabs.init($('.tab-pid_tuning')); @@ -303,6 +387,10 @@ TABS.pid_tuning.initialize = function (callback) { $('.rpy_d').prop('disabled', 'disabled'); } + interval.add("drawRollPitchYawExpo", function () { + drawRollPitchYawExpo(); + }, 100); + GUI.simpleBind(); // UI Hooks diff --git a/tabs/receiver.html b/tabs/receiver.html index fbea3946f..5609b6369 100644 --- a/tabs/receiver.html +++ b/tabs/receiver.html @@ -70,28 +70,13 @@
-
-
- - - -
- -
- - -
- +
- -
@@ -134,43 +119,7 @@
-
-
-
- - - - -
-
- -
-
-
-
- - - - - - - - - -
- - - - - - - - - -
-
-
-
+
diff --git a/tabs/receiver.js b/tabs/receiver.js index 9b20874f0..9046d5d00 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -47,41 +47,6 @@ TABS.receiver.initialize = function (callback) { Settings.saveInputs(onComplete); } - function drawRollPitchExpo() { - var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0); - var context = pitch_roll_curve.getContext("2d"); - - var expoAVal = $('.tunings .rate input[name="expo"]'); - var expoA = parseFloat(expoAVal.val()); - - var expoMVal = $('.tunings .rate input[name="manual_expo"]'); - var expoM = parseFloat(expoMVal.val()); - - if (expoA <= parseFloat(expoAVal.prop('min')) || expoA >= parseFloat(expoAVal.prop('max')) || - expoM <= parseFloat(expoMVal.prop('min')) || expoM >= parseFloat(expoMVal.prop('max'))) { - return; - } - - var rateHeight = TABS.receiver.rateChartHeight; - - // draw - context.clearRect(0, 0, 200, rateHeight); - - context.beginPath(); - context.moveTo(0, rateHeight); - context.quadraticCurveTo(110, rateHeight - ((rateHeight / 2) * (1 - expoA)), 200, 0); - context.lineWidth = 2; - context.strokeStyle = '#37a8db'; - context.stroke(); - - context.beginPath(); - context.moveTo(0, rateHeight); - context.quadraticCurveTo(110, rateHeight - ((rateHeight / 2) * (1 - expoM)), 200, 0); - context.lineWidth = 2; - context.strokeStyle = '#a837db'; - context.stroke(); - } - function process_html() { // translate to user-selected language i18n.localize();; @@ -120,12 +85,6 @@ TABS.receiver.initialize = function (callback) { $('.tunings .throttle input[name="mid"]').val(FC.RC_tuning.throttle_MID.toFixed(2)); $('.tunings .throttle input[name="expo"]').val(FC.RC_tuning.throttle_EXPO.toFixed(2)); - $('.tunings .rate input[name="expo"]').val(FC.RC_tuning.RC_EXPO.toFixed(2)); - $('.tunings .yaw_rate input[name="yaw_expo"]').val(FC.RC_tuning.RC_YAW_EXPO.toFixed(2)); - - $('.tunings .rate input[name="manual_expo"]').val(FC.RC_tuning.manual_RC_EXPO.toFixed(2)); - $('.tunings .yaw_rate input[name="manual_yaw_expo"]').val(FC.RC_tuning.manual_RC_YAW_EXPO.toFixed(2)); - $('.deadband input[name="yaw_deadband"]').val(FC.RC_deadband.yaw_deadband); $('.deadband input[name="deadband"]').val(FC.RC_deadband.deadband); @@ -284,23 +243,11 @@ TABS.receiver.initialize = function (callback) { }, 0); }).trigger('input'); - $('.tunings .rate input').on('input change', function () { - setTimeout(function () { // let global validation trigger and adjust the values first - drawRollPitchExpo(); - }, 0); - }).trigger('input'); - $('a.update').on('click', function () { // catch RC_tuning changes FC.RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); FC.RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); - FC.RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val()); - FC.RC_tuning.RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="yaw_expo"]').val()); - - FC.RC_tuning.manual_RC_EXPO = parseFloat($('.tunings .rate input[name="manual_expo"]').val()); - FC.RC_tuning.manual_RC_YAW_EXPO = parseFloat($('.tunings .yaw_rate input[name="manual_yaw_expo"]').val()); - FC.RC_deadband.yaw_deadband = parseInt($('.deadband input[name="yaw_deadband"]').val()); FC.RC_deadband.deadband = parseInt($('.deadband input[name="deadband"]').val());