From e83314c65cefe43a4194a701f57e3d65c1104226 Mon Sep 17 00:00:00 2001 From: mikeller Date: Wed, 3 Aug 2016 02:26:06 +1200 Subject: [PATCH] Added dterm setpoint weight to PID tab. Added new PID tuning settings. Moved controller parameters to bottom, made them hide when not relevant. --- _locales/en/messages.json | 40 +++++++++++++- js/msp.js | 2 + tabs/pid_tuning.css | 23 ++++++-- tabs/pid_tuning.html | 110 +++++++++++++++++++++++++------------- tabs/pid_tuning.js | 97 ++++++++++++++++++++++++++++----- 5 files changed, 219 insertions(+), 53 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index b7ab35cb..6189252a 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -785,9 +785,36 @@ "pidTuningHideUnusedPids": { "message": "Hide unused PIDs" }, + "pidTuningNonProfilePidSettings": { + "message": "Profile independent PID Controller Settings" + }, "pidTuningPidSettings": { "message": "PID Controller Settings" }, + "pidTuningRcSmoothing": { + "message": "RC Smoothing" + }, + "pidTuningRcSmoothingOff": { + "message": "Off" + }, + "pidTuningRcSmoothingDefault": { + "message": "Default" + }, + "pidTuningRcSmoothingAuto": { + "message": "Auto" + }, + "pidTuningRcSmoothingManual": { + "message": "Manual" + }, + "pidTuningRcSmoothingInterval": { + "message": "RC Smoothing Interval (ms)" + }, + "pidTuningPtermSetpoint": { + "message": "Pterm Setpoint Weight" + }, + "pidTuningDtermSetpoint": { + "message": "Dterm Setpoint Weight" + }, "pidTuningProportional": { "message": "Proportional" }, @@ -846,7 +873,7 @@ "message": "Profile" }, "pidTuningControllerHead": { - "message": "PID" + "message": "PID Controller" }, "pidTuningResetProfile": { "message": "Reset all profile values" @@ -1766,7 +1793,16 @@ "pidTuningRateProfileTip": { "message": "Up to 3 different rateprofiles per profile can be stored on the flight controller. The rateprofiles include the settings for 'RC Rate', 'Rate', 'RC Expo', 'Throttle', and 'TPA'. Switching between rateprofiles is possible in-flight, by setting up a 3 position switch for 'Rate Profile Selection' on the 'Adjustments' tab." }, - "pidTuningPidTip": { + "pidTuningDelta": { + "message": "Derivative Method" + }, + "pidTuningDeltaError": { + "message": "Error" + }, + "pidTuningDeltaMeasurement": { + "message": "Measurement" + }, + "pidTuningDeltaTip": { "message": "Derivative from Error provides more direct stick response and is mostly prefered for Racing.

Derivative from Measurement provides smoother stick response what is more usefull for freestyling" }, "pidTuningPidControllerTip": { diff --git a/js/msp.js b/js/msp.js index 592bb992..42d7af08 100755 --- a/js/msp.js +++ b/js/msp.js @@ -911,7 +911,9 @@ var MSP = { offset += 2; if (semver.gte(CONFIG.apiVersion, "1.20.0")) { RX_CONFIG.rcSmoothing = data.getUint8(offset, 1); + offset++; RX_CONFIG.rcSmoothInterval = data.getUint8(offset, 1); + offset++; RX_CONFIG.airModeActivateThreshold = data.getUint16(offset, 1); } else { RX_CONFIG.rcSmoothing = 0; diff --git a/tabs/pid_tuning.css b/tabs/pid_tuning.css index 1102cd3e..c756aa13 100644 --- a/tabs/pid_tuning.css +++ b/tabs/pid_tuning.css @@ -264,8 +264,25 @@ .tab-pid_tuning .compensation td { padding: 5px; - } +} +.tab-pid_tuning .compensation td:first-child { + width: 20%; + padding-bottom: 6px; + padding-top: 5px; +} + +.tab-pid_tuning .compensation td:last-child { + width: 40%; +} + +.tab-pid_tuning .compensation td { + width: 40%; +} + +.tab-pid_tuning .compensation .slider input { + -webkit-appearance: slider-horizontal +} .tab-pid_tuning table td { padding: 1px; @@ -554,7 +571,7 @@ .tab-pid_tuning .controller { - width: 100px; + width: 150px; } .tab-pid_tuning .controller select { @@ -657,4 +674,4 @@ width: 50%; .tab-pid_tuning .new_rates_last-child { border-bottom: none; -} \ No newline at end of file +} diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 02abb27b..84b9c309 100755 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -41,16 +41,6 @@ -
-
-
Derivative Method
-
- -
-
@@ -64,31 +54,6 @@
- - - - -
- - - - - - - - -
- - -
- -
-
-
-
-
@@ -275,6 +240,79 @@
+
+ + + + +
+ + + + + + + + + + + + +
+ +
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
+ +
+
+
+
@@ -399,4 +437,4 @@ - \ No newline at end of file + diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 6a710554..384b6d8f 100755 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -33,6 +33,10 @@ TABS.pid_tuning.initialize = function (callback) { if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { return MSP.promise(MSP_codes.MSP_PID_ADVANCED); } + }).then(function() { + if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) { + return MSP.promise(MSP_codes.MSP_RX_CONFIG); + } }).then(function() { return MSP.promise(MSP_codes.MSP_RC_TUNING); }).then(function() { @@ -59,7 +63,19 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { - $('.delta select').val(ADVANCED_TUNING.deltaMethod); + $('#pid-tuning .delta select').val(ADVANCED_TUNING.deltaMethod); + } + + if (semver.gte(CONFIG.flightControllerVersion, '3.0.0')) { + $('select[name="rcSmoothing-select"]').val(RX_CONFIG.rcSmoothing); + + $('input[name="rcSmoothingInterval-number"]').val(RX_CONFIG.rcSmoothInterval); + + $('input[name="ptermSetpoint-number"]').val(ADVANCED_TUNING.ptermSetpointWeight / 100); + $('input[name="ptermSetpoint-range"]').val(ADVANCED_TUNING.ptermSetpointWeight / 100); + + $('input[name="dtermSetpoint-number"]').val(ADVANCED_TUNING.dtermSetpointWeight / 100); + $('input[name="dtermSetpoint-range"]').val(ADVANCED_TUNING.dtermSetpointWeight / 100); } // Fill in the data from PIDs array @@ -238,7 +254,17 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { - ADVANCED_TUNING.deltaMethod = $('.delta select').val(); + ADVANCED_TUNING.deltaMethod = $('#pid-tuning .delta select').val(); + } + + if (semver.gte(CONFIG.flightControllerVersion, '3.0.0')) { + RX_CONFIG.rcSmoothing = parseInt($('select[name="rcSmoothing-select"]').val()); + + RX_CONFIG.rcSmoothInterval = parseInt($('input[name="rcSmoothingInterval-number"]').val()); + + ADVANCED_TUNING.ptermSetpointWeight = parseInt($('input[name="ptermSetpoint-number"]').val() * 100); + + ADVANCED_TUNING.dtermSetpointWeight = parseInt($('input[name="dtermSetpoint-number"]').val() * 100); } // Fill in the data from PIDs array @@ -504,10 +530,39 @@ TABS.pid_tuning.initialize = function (callback) { }); }); }); + + var ptermNumberElement = $('input[name="ptermSetpoint-number"]'); + var ptermRangeElement = $('input[name="ptermSetpoint-range"]'); + ptermNumberElement.change(function () { + ptermRangeElement.val($(this).val()); + }); + ptermRangeElement.change(function () { + ptermNumberElement.val($(this).val()); + }); + + var dtermNumberElement = $('input[name="dtermSetpoint-number"]'); + var dtermRangeElement = $('input[name="dtermSetpoint-range"]'); + dtermNumberElement.change(function () { + dtermRangeElement.val($(this).val()); + }); + dtermRangeElement.change(function () { + dtermNumberElement.val($(this).val()); + }); } else { $('.tab-pid_tuning .rate_profile').hide(); + + $('.pid-tuning .rcSmoothing').hide(); + $('.pid-tuning .rcSmoothingInterval').hide(); + + $('.pid-tuning .ptermSetpoint').hide(); + $('.pid-tuning .dtermSetpoint').hide(); } + if (!semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { + $('#pid-tuning .delta').hide(); + $('.tab-pid_tuning .note').hide(); + } + $('.pid_tuning tr').each(function(){ for(i = 0; i < PID_names.length; i++) { if($(this).hasClass(PID_names[i])) { @@ -550,6 +605,8 @@ TABS.pid_tuning.initialize = function (callback) { if (semver.gte(CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion)) { pidController_e.val(PID.controller); + + self.updatePidControllerParameters(); } else { GUI.log(chrome.i18n.getMessage('pidTuningUpgradeFirmwareToChangePidController', [CONFIG.apiVersion, CONFIGURATOR.pidControllerChangeMinApiVersion])); @@ -695,22 +752,24 @@ TABS.pid_tuning.initialize = function (callback) { }); $('#pid-tuning').find('input').each(function (k, item) { - $(item).change(function () { - self.setDirty(true); - }) + if ($(item).attr('class') !== "feature toggle" + && $(item).attr('class') !== "nonProfile") { + $(item).change(function () { + self.setDirty(true); + }); + } }); pidController_e.change(function () { self.setDirty(true); + + self.updatePidControllerParameters(); }); if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { - $('.delta select').change(function() { + $('#pid-tuning .delta select').change(function() { self.setDirty(true); }); - } else { - $('.delta').hide(); - $('.note').hide(); } // update == save. @@ -736,6 +795,10 @@ TABS.pid_tuning.initialize = function (callback) { if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { return MSP.promise(MSP_codes.MSP_SET_PID_ADVANCED, MSP.crunch(MSP_codes.MSP_SET_PID_ADVANCED)); } + }).then(function () { + if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) { + return MSP.promise(MSP_codes.MSP_SET_RX_CONFIG, MSP.crunch(MSP_codes.MSP_SET_RX_CONFIG)); + } }).then(function () { if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) { return MSP.promise(MSP_codes.MSP_SET_FILTER_CONFIG, MSP.crunch(MSP_codes.MSP_SET_FILTER_CONFIG)); @@ -892,8 +955,18 @@ TABS.pid_tuning.checkUpdateProfile = function (updateRateProfile) { } } -TABS.pid_tuning.setUpdating = function (isUpdating) { - var self = this; +TABS.pid_tuning.updatePidControllerParameters = function () { + if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) { + if ($('.tab-pid_tuning select[name="controller"]').val() === '0') { + $('#pid-tuning .delta').show(); - self.updating = isUpdating; + $('#pid-tuning .ptermSetpoint').hide(); + $('#pid-tuning .dtermSetpoint').hide(); + } else { + $('#pid-tuning .ptermSetpoint').show(); + $('#pid-tuning .dtermSetpoint').show(); + + $('#pid-tuning .delta').hide(); + } + } }