mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-15 04:15:32 +03:00
Add support for firmware side sliders
This commit is contained in:
parent
de071bc136
commit
41fb373c94
9 changed files with 485 additions and 260 deletions
|
@ -3594,6 +3594,22 @@
|
||||||
"message": "Master Multiplier:",
|
"message": "Master Multiplier:",
|
||||||
"description": "Master tuning slider label"
|
"description": "Master tuning slider label"
|
||||||
},
|
},
|
||||||
|
"pidTuningRollPitchRatioSlider": {
|
||||||
|
"message": "Roll Pitch Ratio:",
|
||||||
|
"description": "Roll pitch ratio slider label"
|
||||||
|
},
|
||||||
|
"pidTuningRollPitchRatioSliderHelp": {
|
||||||
|
"message": "Roll Pitch Ratio",
|
||||||
|
"description": "This needs a meaningful help text"
|
||||||
|
},
|
||||||
|
"pidTuningIGainSlider": {
|
||||||
|
"message": "I Gain:",
|
||||||
|
"description": "I gain slider label"
|
||||||
|
},
|
||||||
|
"pidTuningIGainSliderHelp": {
|
||||||
|
"message": "I Gain",
|
||||||
|
"description": "This needs a meaningful help text"
|
||||||
|
},
|
||||||
"pidTuningPDRatioSlider": {
|
"pidTuningPDRatioSlider": {
|
||||||
"message": "PD Balance:",
|
"message": "PD Balance:",
|
||||||
"description": "PD balance tuning slider label"
|
"description": "PD balance tuning slider label"
|
||||||
|
@ -3602,6 +3618,14 @@
|
||||||
"message": "P and D Gain:",
|
"message": "P and D Gain:",
|
||||||
"description": "P and D gain tuning slider label"
|
"description": "P and D gain tuning slider label"
|
||||||
},
|
},
|
||||||
|
"pidTuningDMinRatioSlider": {
|
||||||
|
"message": "D Min Ratio:",
|
||||||
|
"description": "D Min ratio slider label"
|
||||||
|
},
|
||||||
|
"pidTuningDMinRatioSliderHelp": {
|
||||||
|
"message": "D Min Ratio",
|
||||||
|
"description": "This needs a meaningful help text"
|
||||||
|
},
|
||||||
"pidTuningResponseSlider": {
|
"pidTuningResponseSlider": {
|
||||||
"message": "Stick Response Gain:",
|
"message": "Stick Response Gain:",
|
||||||
"description": "Response tuning slider label"
|
"description": "Response tuning slider label"
|
||||||
|
|
|
@ -734,7 +734,7 @@
|
||||||
height: 15px;
|
height: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-pid_tuning .nonExpertModeSliders.tuningSlider::-webkit-slider-runnable-track {
|
.tab-pid_tuning .nonExpertModeSliders .tuningSlider::-webkit-slider-runnable-track {
|
||||||
background: linear-gradient(90deg, rgb(197, 197, 197) -50%, rgb(241, 241, 241) 50%, rgb(255, 84, 14) 150%);
|
background: linear-gradient(90deg, rgb(197, 197, 197) -50%, rgb(241, 241, 241) 50%, rgb(255, 84, 14) 150%);
|
||||||
background-size: 55%;
|
background-size: 55%;
|
||||||
background-position: 44%;
|
background-position: 44%;
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const TuningSliders = {
|
const TuningSliders = {
|
||||||
MasterSliderValue: 1,
|
sliderPidsMode: 0,
|
||||||
PDRatioSliderValue: 1,
|
sliderMasterMultiplier: 1,
|
||||||
PDGainSliderValue: 1,
|
sliderRollPitchRatio: 1,
|
||||||
ResponseSliderValue: 1,
|
sliderIGain: 1,
|
||||||
|
sliderPDRatio: 1,
|
||||||
|
sliderPDGain: 1,
|
||||||
|
sliderDMinRatio: 1,
|
||||||
|
sliderFFGain: 1,
|
||||||
pidSlidersUnavailable: false,
|
pidSlidersUnavailable: false,
|
||||||
|
|
||||||
gyroFilterSliderValue: 1,
|
sliderGyroFilter: 0,
|
||||||
dtermFilterSliderValue: 1,
|
sliderGyroFilterMultiplier: 1,
|
||||||
filterGyroSliderUnavailable: false,
|
sliderDTermFilter: 0,
|
||||||
filterDTermSliderUnavailable: false,
|
sliderDTermFilterMultiplier: 1,
|
||||||
|
|
||||||
dMinFeatureEnabled: true,
|
|
||||||
defaultPDRatio: 0,
|
|
||||||
PID_DEFAULT: [],
|
PID_DEFAULT: [],
|
||||||
FILTER_DEFAULT: {},
|
FILTER_DEFAULT: {},
|
||||||
|
|
||||||
|
@ -30,7 +32,6 @@ TuningSliders.initialize = function() {
|
||||||
this.PID_DEFAULT = FC.getPidDefaults();
|
this.PID_DEFAULT = FC.getPidDefaults();
|
||||||
this.FILTER_DEFAULT = FC.getFilterDefaults();
|
this.FILTER_DEFAULT = FC.getFilterDefaults();
|
||||||
|
|
||||||
this.setDMinFeatureEnabled($('#dMinSwitch').is(':checked'));
|
|
||||||
this.setExpertMode($('input[name="expertModeCheckbox"]').is(':checked'));
|
this.setExpertMode($('input[name="expertModeCheckbox"]').is(':checked'));
|
||||||
|
|
||||||
this.initPidSlidersPosition();
|
this.initPidSlidersPosition();
|
||||||
|
@ -46,29 +47,18 @@ TuningSliders.initialize = function() {
|
||||||
this.updateFilterSlidersDisplay();
|
this.updateFilterSlidersDisplay();
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.setDMinFeatureEnabled = function(dMinFeatureEnabled) {
|
|
||||||
this.dMinFeatureEnabled = dMinFeatureEnabled;
|
|
||||||
if (this.dMinFeatureEnabled) {
|
|
||||||
this.defaultPDRatio = this.PID_DEFAULT[2] / this.PID_DEFAULT[0];
|
|
||||||
} else {
|
|
||||||
this.defaultPDRatio = this.PID_DEFAULT[2] / (this.PID_DEFAULT[0] * (1 / D_MIN_RATIO));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TuningSliders.setExpertMode = function(expertMode) {
|
TuningSliders.setExpertMode = function(expertMode) {
|
||||||
this.expertMode = expertMode;
|
this.expertMode = expertMode;
|
||||||
const allTuningSliderElements = $('#tuningMasterSlider, #tuningPDRatioSlider, #tuningPDGainSlider,\
|
|
||||||
#tuningResponseSlider, #tuningGyroFilterSlider, #tuningDTermFilterSlider');
|
|
||||||
if (this.expertMode) {
|
if (this.expertMode) {
|
||||||
allTuningSliderElements.removeClass('nonExpertModeSliders');
|
$('#slidersPidsBox, #slidersFilterBox').removeClass('nonExpertModeSliders');
|
||||||
} else {
|
} else {
|
||||||
allTuningSliderElements.addClass('nonExpertModeSliders');
|
$('#slidersPidsBox, #slidersFilterBox').addClass('nonExpertModeSliders');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.scaleSliderValue = function(value) {
|
TuningSliders.scaleSliderValue = function(value) {
|
||||||
if (value > 1) {
|
if (value > 1) {
|
||||||
return Math.round(((value - 1) * 2 + 1) * 10) / 10;
|
return Math.round(((value - 1) * 2 + 1) * 100) / 100;
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -83,71 +73,115 @@ TuningSliders.downscaleSliderValue = function(value) {
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.initPidSlidersPosition = function() {
|
TuningSliders.initPidSlidersPosition = function() {
|
||||||
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
// used to estimate PID slider positions based on PIDF values, and set respective slider position
|
// used to estimate PID slider positions based on PIDF values, and set respective slider position
|
||||||
// provides only an estimation due to limitation of feature without firmware support, to be improved in later versions
|
// provides only an estimation due to limitation of feature without firmware support, to be improved in later versions
|
||||||
this.MasterSliderValue = Math.round(FC.PIDS[2][1] / this.PID_DEFAULT[11] * 10) / 10;
|
this.sliderMasterMultiplier = Math.floor(FC.PIDS[2][1] / this.PID_DEFAULT[11] * 10) / 10;
|
||||||
this.PDRatioSliderValue = Math.round(FC.PIDS[0][2] / FC.PIDS[0][0] / this.defaultPDRatio * 10) / 10;
|
this.sliderPDRatio = Math.floor(FC.PIDS[0][0] / FC.PIDS[0][2] / (this.PID_DEFAULT[0] / this.PID_DEFAULT[2]) * 10) / 10;
|
||||||
if (this.dMinFeatureEnabled) {
|
this.sliderPDGain = Math.floor(FC.ADVANCED_TUNING.dMinRoll / this.sliderMasterMultiplier / this.PID_DEFAULT[3] * 10) / 10;
|
||||||
this.PDGainSliderValue = Math.round(FC.ADVANCED_TUNING.dMinRoll / this.PDRatioSliderValue / this.MasterSliderValue / this.PID_DEFAULT[3] * 10) / 10;
|
this.sliderFFGain = Math.floor(FC.ADVANCED_TUNING.feedforwardRoll / this.sliderMasterMultiplier / this.PID_DEFAULT[4] * 10) / 10;
|
||||||
} else {
|
} else {
|
||||||
this.PDGainSliderValue = Math.round(FC.PIDS[0][0] / this.MasterSliderValue / (this.PID_DEFAULT[2] * (1 / D_MIN_RATIO)) * 10) / 10;
|
this.sliderPidsMode = FC.TUNING_SLIDERS.slider_pids_mode;
|
||||||
|
this.sliderMasterMultiplier = FC.TUNING_SLIDERS.slider_master_multiplier / 100;
|
||||||
|
this.sliderRollPitchRatio = FC.TUNING_SLIDERS.slider_roll_pitch_ratio / 100;
|
||||||
|
this.sliderIGain = FC.TUNING_SLIDERS.slider_i_gain / 100;
|
||||||
|
this.sliderPDRatio = FC.TUNING_SLIDERS.slider_pd_ratio / 100;
|
||||||
|
this.sliderPDGain = FC.TUNING_SLIDERS.slider_pd_gain / 100;
|
||||||
|
this.sliderDMinRatio = FC.TUNING_SLIDERS.slider_dmin_ratio / 100;
|
||||||
|
this.sliderFFGain = FC.TUNING_SLIDERS.slider_ff_gain / 100;
|
||||||
}
|
}
|
||||||
this.ResponseSliderValue = Math.round(FC.ADVANCED_TUNING.feedforwardRoll / this.MasterSliderValue / this.PID_DEFAULT[4] * 10) / 10;
|
|
||||||
|
|
||||||
$('output[name="tuningMasterSlider-number"]').val(this.MasterSliderValue);
|
$('output[name="sliderMasterMultiplier-number"]').val(this.sliderMasterMultiplier);
|
||||||
$('output[name="tuningPDRatioSlider-number"]').val(this.PDRatioSliderValue);
|
$('output[name="sliderRollPitchRatio-number"]').val(this.sliderRollPitchRatio);
|
||||||
$('output[name="tuningPDGainSlider-number"]').val(this.PDGainSliderValue);
|
$('output[name="sliderIGain-number"]').val(this.sliderIGain);
|
||||||
$('output[name="tuningResponseSlider-number"]').val(this.ResponseSliderValue);
|
$('output[name="sliderPDRatio-number"]').val(this.sliderPDRatio);
|
||||||
|
$('output[name="sliderPDGain-number"]').val(this.sliderPDGain);
|
||||||
|
$('output[name="sliderDMinRatio-number"]').val(this.sliderDMinRatio);
|
||||||
|
$('output[name="sliderFFGain-number"]').val(this.sliderFFGain);
|
||||||
|
|
||||||
$('#tuningMasterSlider').val(this.downscaleSliderValue(this.MasterSliderValue));
|
$('#sliderMasterMultiplier').val(this.downscaleSliderValue(this.sliderMasterMultiplier));
|
||||||
$('#tuningPDRatioSlider').val(this.downscaleSliderValue(this.PDRatioSliderValue));
|
$('#sliderRollPitchRatio').val(this.downscaleSliderValue(this.sliderRollPitchRatio));
|
||||||
$('#tuningPDGainSlider').val(this.downscaleSliderValue(this.PDGainSliderValue));
|
$('#sliderIGain').val(this.downscaleSliderValue(this.sliderIGain));
|
||||||
$('#tuningResponseSlider').val(this.downscaleSliderValue(this.ResponseSliderValue));
|
$('#sliderPDRatio').val(this.downscaleSliderValue(this.sliderPDRatio));
|
||||||
|
$('#sliderPDGain').val(this.downscaleSliderValue(this.sliderPDGain));
|
||||||
|
$('#sliderDMinRatio').val(this.downscaleSliderValue(this.sliderDMinRatio));
|
||||||
|
$('#sliderFFGain').val(this.downscaleSliderValue(this.sliderFFGain));
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.initGyroFilterSliderPosition = function() {
|
TuningSliders.initGyroFilterSliderPosition = function() {
|
||||||
this.gyroFilterSliderValue = Math.round((FC.FILTER_CONFIG.gyro_lowpass_dyn_min_hz + FC.FILTER_CONFIG.gyro_lowpass_dyn_max_hz + FC.FILTER_CONFIG.gyro_lowpass2_hz) /
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
this.sliderGyroFilterMultiplier = Math.floor((FC.FILTER_CONFIG.gyro_lowpass_dyn_min_hz + FC.FILTER_CONFIG.gyro_lowpass_dyn_max_hz + FC.FILTER_CONFIG.gyro_lowpass2_hz) /
|
||||||
(this.FILTER_DEFAULT.gyro_lowpass_dyn_min_hz + this.FILTER_DEFAULT.gyro_lowpass_dyn_max_hz + this.FILTER_DEFAULT.gyro_lowpass2_hz) * 100) / 100;
|
(this.FILTER_DEFAULT.gyro_lowpass_dyn_min_hz + this.FILTER_DEFAULT.gyro_lowpass_dyn_max_hz + this.FILTER_DEFAULT.gyro_lowpass2_hz) * 100) / 100;
|
||||||
$('output[name="tuningGyroFilterSlider-number"]').val(this.gyroFilterSliderValue);
|
} else {
|
||||||
$('#tuningGyroFilterSlider').val(this.downscaleSliderValue(this.gyroFilterSliderValue));
|
this.sliderGyroFilterMultiplier = FC.TUNING_SLIDERS.slider_gyro_filter_multiplier / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('output[name="sliderGyroFilterMultiplier-number"]').val(this.sliderGyroFilterMultiplier);
|
||||||
|
$('#sliderGyroFilterMultiplier').val(this.downscaleSliderValue(this.sliderGyroFilterMultiplier));
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.initDTermFilterSliderPosition = function() {
|
TuningSliders.initDTermFilterSliderPosition = function() {
|
||||||
this.dtermFilterSliderValue = Math.round((FC.FILTER_CONFIG.dterm_lowpass_dyn_min_hz + FC.FILTER_CONFIG.dterm_lowpass_dyn_max_hz + FC.FILTER_CONFIG.dterm_lowpass2_hz) /
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
this.sliderDTermFilterMultiplier = Math.floor((FC.FILTER_CONFIG.dterm_lowpass_dyn_min_hz + FC.FILTER_CONFIG.dterm_lowpass_dyn_max_hz + FC.FILTER_CONFIG.dterm_lowpass2_hz) /
|
||||||
(this.FILTER_DEFAULT.dterm_lowpass_dyn_min_hz + this.FILTER_DEFAULT.dterm_lowpass_dyn_max_hz + this.FILTER_DEFAULT.dterm_lowpass2_hz) * 100) / 100;
|
(this.FILTER_DEFAULT.dterm_lowpass_dyn_min_hz + this.FILTER_DEFAULT.dterm_lowpass_dyn_max_hz + this.FILTER_DEFAULT.dterm_lowpass2_hz) * 100) / 100;
|
||||||
$('output[name="tuningDTermFilterSlider-number"]').val(this.dtermFilterSliderValue);
|
} else {
|
||||||
$('#tuningDTermFilterSlider').val(this.downscaleSliderValue(this.dtermFilterSliderValue));
|
this.sliderDTermFilterMultiplier = FC.TUNING_SLIDERS.slider_dterm_filter_multiplier / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('output[name="sliderDTermFilterMultiplier-number"]').val(this.sliderDTermFilterMultiplier);
|
||||||
|
$('#sliderDTermFilterMultiplier').val(this.downscaleSliderValue(this.sliderDTermFilterMultiplier));
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.resetPidSliders = function() {
|
TuningSliders.resetPidSliders = function() {
|
||||||
if (!this.cachedPidSliderValues) {
|
if (!this.cachedPidSliderValues) {
|
||||||
$('#tuningMasterSlider').val(1);
|
this.sliderMasterMultiplier = 1;
|
||||||
$('#tuningPDRatioSlider').val(1);
|
this.sliderRollPitchRatio = 1;
|
||||||
$('#tuningPDGainSlider').val(1);
|
this.sliderIGain = 1;
|
||||||
$('#tuningResponseSlider').val(1);
|
this.sliderPDRatio = 1;
|
||||||
this.MasterSliderValue = 1;
|
this.sliderPDGain = 1;
|
||||||
this.PDRatioSliderValue = 1;
|
this.sliderDMinRatio = 1;
|
||||||
this.PDGainSliderValue = 1;
|
this.sliderFFGain = 1;
|
||||||
this.ResponseSliderValue = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
$('#sliderMasterMultiplier').val(this.downscaleSliderValue(this.sliderMasterMultiplier));
|
||||||
|
$('#sliderPDRatio').val(this.downscaleSliderValue(this.sliderPDRatio));
|
||||||
|
$('#sliderPDGain').val(this.downscaleSliderValue(this.sliderPDGain));
|
||||||
|
$('#sliderFFGain').val(this.downscaleSliderValue(this.sliderFFGain));
|
||||||
|
} else {
|
||||||
|
this.initPidSlidersPosition();
|
||||||
|
}
|
||||||
|
|
||||||
this.calculateNewPids();
|
this.calculateNewPids();
|
||||||
this.updatePidSlidersDisplay();
|
this.updatePidSlidersDisplay();
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.resetGyroFilterSlider = function() {
|
TuningSliders.resetGyroFilterSlider = function() {
|
||||||
if (!this.cachedGyroSliderValues) {
|
if (!this.cachedGyroSliderValues) {
|
||||||
$('#tuningGyroFilterSlider').val(1);
|
this.sliderGyroFilterMultiplier = 1;
|
||||||
this.gyroFilterSliderValue = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
$('#sliderGyroFilterMultiplier').val(this.downscaleSliderValue(this.sliderGyroFilterMultiplier));
|
||||||
|
} else {
|
||||||
|
this.initGyroFilterSliderPosition();
|
||||||
|
}
|
||||||
|
|
||||||
this.calculateNewGyroFilters();
|
this.calculateNewGyroFilters();
|
||||||
this.updateFilterSlidersDisplay();
|
this.updateFilterSlidersDisplay();
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.resetDTermFilterSlider = function() {
|
TuningSliders.resetDTermFilterSlider = function() {
|
||||||
if (!this.cachedDTermSliderValues) {
|
if (!this.cachedDTermSliderValues) {
|
||||||
$('#tuningDTermFilterSlider').val(1);
|
this.sliderDTermFilterMultiplier = 1;
|
||||||
this.dtermFilterSliderValue = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
$('#sliderDTermFilterMultiplier').val(this.downscaleSliderValue(this.sliderDTermFilterMultiplier));
|
||||||
|
} else {
|
||||||
|
this.initDTermFilterSliderPosition();
|
||||||
|
}
|
||||||
|
|
||||||
this.calculateNewDTermFilters();
|
this.calculateNewDTermFilters();
|
||||||
this.updateFilterSlidersDisplay();
|
this.updateFilterSlidersDisplay();
|
||||||
};
|
};
|
||||||
|
@ -160,11 +194,12 @@ TuningSliders.updatePidSlidersDisplay = function() {
|
||||||
const WARNING_DMAX_GAIN = 60;
|
const WARNING_DMAX_GAIN = 60;
|
||||||
const WARNING_DMIN_GAIN = 40;
|
const WARNING_DMIN_GAIN = 40;
|
||||||
|
|
||||||
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
this.pidSlidersUnavailable = false;
|
this.pidSlidersUnavailable = false;
|
||||||
let currentPIDs = [];
|
let currentPIDs = [];
|
||||||
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
|
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
|
||||||
let searchRow = $('.pid_tuning .' + elementPid + ' input');
|
const pidElements = $(`.pid_tuning .${elementPid} input`);
|
||||||
searchRow.each(function (indexInput) {
|
pidElements.each(function (indexInput) {
|
||||||
if (indexPid < 3 && indexInput < 5) {
|
if (indexPid < 3 && indexInput < 5) {
|
||||||
currentPIDs.push($(this).val());
|
currentPIDs.push($(this).val());
|
||||||
}
|
}
|
||||||
|
@ -172,8 +207,8 @@ TuningSliders.updatePidSlidersDisplay = function() {
|
||||||
});
|
});
|
||||||
this.calculateNewPids();
|
this.calculateNewPids();
|
||||||
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
|
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
|
||||||
let searchRow = $('.pid_tuning .' + elementPid + ' input');
|
const pidElements = $(`.pid_tuning .${elementPid} input`);
|
||||||
searchRow.each(function (indexInput) {
|
pidElements.each(function (indexInput) {
|
||||||
if (indexPid < 3 && indexInput < 5) {
|
if (indexPid < 3 && indexInput < 5) {
|
||||||
if (currentPIDs[indexPid * 5 + indexInput] != $(this).val()) {
|
if (currentPIDs[indexPid * 5 + indexInput] != $(this).val()) {
|
||||||
TuningSliders.pidSlidersUnavailable = true;
|
TuningSliders.pidSlidersUnavailable = true;
|
||||||
|
@ -187,11 +222,10 @@ TuningSliders.updatePidSlidersDisplay = function() {
|
||||||
this.pidSlidersUnavailable = true;
|
this.pidSlidersUnavailable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pidSlidersUnavailable) {
|
if (!this.pidSlidersUnavailable) {
|
||||||
TABS.pid_tuning.updatePIDColors(true);
|
|
||||||
} else {
|
|
||||||
this.cachedPidSliderValues = true;
|
this.cachedPidSliderValues = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$('.tuningPIDSliders').toggle(!this.pidSlidersUnavailable);
|
$('.tuningPIDSliders').toggle(!this.pidSlidersUnavailable);
|
||||||
$('.subtab-pid .slidersDisabled').toggle(this.pidSlidersUnavailable);
|
$('.subtab-pid .slidersDisabled').toggle(this.pidSlidersUnavailable);
|
||||||
|
@ -205,72 +239,78 @@ TuningSliders.updateFilterSlidersDisplay = function() {
|
||||||
const WARNING_FILTER_HIGH_GAIN = 1.4;
|
const WARNING_FILTER_HIGH_GAIN = 1.4;
|
||||||
const WARNING_FILTER_LOW_GAIN = 0.7;
|
const WARNING_FILTER_LOW_GAIN = 0.7;
|
||||||
|
|
||||||
this.filterGyroSliderUnavailable = false;
|
this.sliderGyroFilter = false;
|
||||||
this.filterDTermSliderUnavailable = false;
|
this.sliderDTermFilter = false;
|
||||||
|
|
||||||
if (parseInt($('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val(), 10) !== Math.round(this.FILTER_DEFAULT.gyro_lowpass_dyn_min_hz * this.gyroFilterSliderValue) ||
|
if ($('.pid_filter input[name="gyroLowpassDynMinFrequency"]').val() !== Math.floor(this.FILTER_DEFAULT.gyro_lowpass_dyn_min_hz * this.sliderGyroFilterMultiplier) ||
|
||||||
parseInt($('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').val(), 10) !== Math.round(this.FILTER_DEFAULT.gyro_lowpass_dyn_max_hz * this.gyroFilterSliderValue) ||
|
$('.pid_filter input[name="gyroLowpassDynMaxFrequency"]').val() !== Math.floor(this.FILTER_DEFAULT.gyro_lowpass_dyn_max_hz * this.sliderGyroFilterMultiplier) ||
|
||||||
parseInt($('.pid_filter select[name="gyroLowpassDynType"]').val(), 10) !== this.FILTER_DEFAULT.gyro_lowpass_type ||
|
$('.pid_filter select[name="gyroLowpassDynType"]').val() !== this.FILTER_DEFAULT.gyro_lowpass_type ||
|
||||||
parseInt($('.pid_filter input[name="gyroLowpass2Frequency"]').val(), 10) !== Math.round(this.FILTER_DEFAULT.gyro_lowpass2_hz * this.gyroFilterSliderValue) ||
|
$('.pid_filter input[name="gyroLowpass2Frequency"]').val() !== Math.floor(this.FILTER_DEFAULT.gyro_lowpass2_hz * this.sliderGyroFilterMultiplier) ||
|
||||||
parseInt($('.pid_filter select[name="gyroLowpass2Type"]').val(), 10) !== this.FILTER_DEFAULT.gyro_lowpass2_type) {
|
$('.pid_filter select[name="gyroLowpass2Type"]').val() !== this.FILTER_DEFAULT.gyro_lowpass2_type) {
|
||||||
|
|
||||||
$('.tuningFilterSliders .sliderLabels tr:nth-child(2)').hide();
|
$('.tuningFilterSliders .sliderLabels tr:first-child').hide();
|
||||||
this.filterGyroSliderUnavailable = true;
|
this.sliderGyroFilter = true;
|
||||||
} else {
|
} else {
|
||||||
$('.tuningFilterSliders .sliderLabels tr:nth-child(2)').show()
|
$('.tuningFilterSliders .sliderLabels tr:nth-child(2)').show()
|
||||||
this.cachedGyroSliderValues = true;
|
this.cachedGyroSliderValues = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt($('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val(), 10) !== Math.round(this.FILTER_DEFAULT.dterm_lowpass_dyn_min_hz * this.dtermFilterSliderValue) ||
|
if ($('.pid_filter input[name="dtermLowpassDynMinFrequency"]').val() !== Math.floor(this.FILTER_DEFAULT.dterm_lowpass_dyn_min_hz * this.sliderDTermFilterMultiplier) ||
|
||||||
parseInt($('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').val(), 10) !== Math.round(this.FILTER_DEFAULT.dterm_lowpass_dyn_max_hz * this.dtermFilterSliderValue) ||
|
$('.pid_filter input[name="dtermLowpassDynMaxFrequency"]').val() !== Math.floor(this.FILTER_DEFAULT.dterm_lowpass_dyn_max_hz * this.sliderDTermFilterMultiplier) ||
|
||||||
parseInt($('.pid_filter select[name="dtermLowpassDynType"]').val(), 10) !== this.FILTER_DEFAULT.dterm_lowpass_type ||
|
$('.pid_filter select[name="dtermLowpassDynType"]').val() !== this.FILTER_DEFAULT.dterm_lowpass_type ||
|
||||||
parseInt($('.pid_filter input[name="dtermLowpass2Frequency"]').val(), 10) !== Math.round(this.FILTER_DEFAULT.dterm_lowpass2_hz * this.dtermFilterSliderValue) ||
|
$('.pid_filter input[name="dtermLowpass2Frequency"]').val() !== Math.floor(this.FILTER_DEFAULT.dterm_lowpass2_hz * this.sliderDTermFilterMultiplier) ||
|
||||||
parseInt($('.pid_filter select[name="dtermLowpass2Type"]').val(), 10) !== this.FILTER_DEFAULT.dterm_lowpass2_type) {
|
$('.pid_filter select[name="dtermLowpass2Type"]').val() !== this.FILTER_DEFAULT.dterm_lowpass2_type) {
|
||||||
|
|
||||||
$('.tuningFilterSliders .sliderLabels tr:last-child').hide();
|
$('.tuningFilterSliders .sliderLabels tr:last-child').hide();
|
||||||
this.filterDTermSliderUnavailable = true;
|
this.sliderDTermFilter = true;
|
||||||
} else {
|
} else {
|
||||||
$('.tuningFilterSliders .sliderLabels tr:last-child').show();
|
$('.tuningFilterSliders .sliderLabels tr:last-child').show();
|
||||||
this.cachedDTermSliderValues = true;
|
this.cachedDTermSliderValues = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.tuningFilterSliders').toggle(!(this.filterGyroSliderUnavailable && this.filterDTermSliderUnavailable));
|
$('.tuningFilterSliders').toggle(!(this.sliderGyroFilter && this.sliderDTermFilter));
|
||||||
$('.subtab-filter .slidersDisabled').toggle(this.filterGyroSliderUnavailable || this.filterDTermSliderUnavailable);
|
$('.subtab-filter .slidersDisabled').toggle(this.sliderGyroFilter || this.sliderDTermFilter);
|
||||||
$('.subtab-filter .nonExpertModeSlidersNote').toggle((!this.filterGyroSliderUnavailable || !this.filterDTermSliderUnavailable) && !this.expertMode);
|
$('.subtab-filter .nonExpertModeSlidersNote').toggle((!this.sliderGyroFilter || !this.sliderDTermFilter) && !this.expertMode);
|
||||||
$('.subtab-filter .slidersWarning').toggle(((this.gyroFilterSliderValue >= WARNING_FILTER_HIGH_GAIN ||
|
$('.subtab-filter .slidersWarning').toggle(((this.sliderGyroFilterMultiplier >= WARNING_FILTER_HIGH_GAIN ||
|
||||||
this.gyroFilterSliderValue <= WARNING_FILTER_LOW_GAIN) && !this.filterGyroSliderUnavailable) ||
|
this.sliderGyroFilterMultiplier <= WARNING_FILTER_LOW_GAIN) && !this.sliderGyroFilter) ||
|
||||||
((this.dtermFilterSliderValue >= WARNING_FILTER_HIGH_GAIN ||
|
((this.sliderDTermFilterMultiplier >= WARNING_FILTER_HIGH_GAIN ||
|
||||||
this.dtermFilterSliderValue <= WARNING_FILTER_LOW_GAIN) && !this.filterDTermSliderUnavailable));
|
this.sliderDTermFilterMultiplier <= WARNING_FILTER_LOW_GAIN) && !this.sliderDTermFilter));
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.calculateNewPids = function() {
|
TuningSliders.updateFormPids = function() {
|
||||||
// this is the main calculation for PID sliders, inputs are in form of slider position values
|
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
|
||||||
// values get set both into forms and their respective variables
|
const pidElements = $(`.pid_tuning .${elementPid} input`);
|
||||||
|
pidElements.each(function (indexInput) {
|
||||||
|
if (indexPid < 3 && indexInput < 3) {
|
||||||
|
$(this).val(FC.PIDS[indexPid][indexInput]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
TuningSliders.legacyCalculateNewPids = function() {
|
||||||
const MAX_PID_GAIN = 200;
|
const MAX_PID_GAIN = 200;
|
||||||
const MAX_DMIN_GAIN = 100;
|
const MAX_DMIN_GAIN = 100;
|
||||||
const MAX_FF_GAIN = 2000;
|
const MAX_FF_GAIN = 2000;
|
||||||
|
|
||||||
|
// only used for 4.1 where calculation is not done in firmware
|
||||||
if (this.dMinFeatureEnabled) {
|
if (this.dMinFeatureEnabled) {
|
||||||
//dmin
|
//dmin
|
||||||
FC.ADVANCED_TUNING.dMinRoll = Math.round(this.PID_DEFAULT[3] * this.PDGainSliderValue * this.PDRatioSliderValue);
|
FC.ADVANCED_TUNING.dMinRoll = Math.floor(this.PID_DEFAULT[3] * this.sliderPDGain);
|
||||||
FC.ADVANCED_TUNING.dMinPitch = Math.round(this.PID_DEFAULT[8] * this.PDGainSliderValue * this.PDRatioSliderValue);
|
FC.ADVANCED_TUNING.dMinPitch = Math.floor(this.PID_DEFAULT[8] * this.sliderPDGain);
|
||||||
// dmax
|
// dmax
|
||||||
FC.PIDS[0][2] = Math.round(this.PID_DEFAULT[2] * this.PDGainSliderValue * this.PDRatioSliderValue);
|
FC.PIDS[0][2] = Math.floor(this.PID_DEFAULT[2] * this.sliderPDGain);
|
||||||
FC.PIDS[1][2] = Math.round(this.PID_DEFAULT[7] * this.PDGainSliderValue * this.PDRatioSliderValue);
|
FC.PIDS[1][2] = Math.floor(this.PID_DEFAULT[7] * this.sliderPDGain);
|
||||||
} else {
|
} else {
|
||||||
FC.ADVANCED_TUNING.dMinRoll = 0;
|
FC.ADVANCED_TUNING.dMinRoll = 0;
|
||||||
FC.ADVANCED_TUNING.dMinPitch = 0;
|
FC.ADVANCED_TUNING.dMinPitch = 0;
|
||||||
FC.PIDS[0][2] = Math.round((this.PID_DEFAULT[2] * D_MIN_RATIO) * this.PDGainSliderValue * this.PDRatioSliderValue);
|
FC.PIDS[0][2] = Math.floor(this.PID_DEFAULT[3] * this.sliderPDGain);
|
||||||
FC.PIDS[1][2] = Math.round((this.PID_DEFAULT[7] * D_MIN_RATIO) * this.PDGainSliderValue * this.PDRatioSliderValue);
|
FC.PIDS[1][2] = Math.floor(this.PID_DEFAULT[8] * this.sliderPDGain);
|
||||||
}
|
}
|
||||||
// p
|
|
||||||
FC.PIDS[0][0] = Math.round(this.PID_DEFAULT[0] * this.PDGainSliderValue);
|
FC.PIDS[0][0] = Math.floor(FC.PIDS[0][2] * this.PID_DEFAULT[0] / this.PID_DEFAULT[2] * this.sliderPDRatio);
|
||||||
FC.PIDS[1][0] = Math.round(this.PID_DEFAULT[5] * this.PDGainSliderValue);
|
FC.PIDS[1][0] = Math.floor(FC.PIDS[1][2] * this.PID_DEFAULT[5] / this.PID_DEFAULT[7] * this.sliderPDRatio);
|
||||||
FC.PIDS[2][0] = Math.round(this.PID_DEFAULT[10] * this.PDGainSliderValue);
|
FC.PIDS[2][0] = Math.floor(this.PID_DEFAULT[10] * this.sliderPDGain);
|
||||||
// ff
|
|
||||||
FC.ADVANCED_TUNING.feedforwardRoll = Math.round(this.PID_DEFAULT[4] * this.ResponseSliderValue);
|
|
||||||
FC.ADVANCED_TUNING.feedforwardPitch = Math.round(this.PID_DEFAULT[9] * this.ResponseSliderValue);
|
|
||||||
FC.ADVANCED_TUNING.feedforwardYaw = Math.round(this.PID_DEFAULT[14] * this.ResponseSliderValue);
|
|
||||||
|
|
||||||
// master slider part
|
// master slider part
|
||||||
// these are not calculated anywhere other than master slider multiplier therefore set at default before every calculation
|
// these are not calculated anywhere other than master slider multiplier therefore set at default before every calculation
|
||||||
|
@ -284,32 +324,65 @@ TuningSliders.calculateNewPids = function() {
|
||||||
//master slider multiplication, max value 200 for main PID values
|
//master slider multiplication, max value 200 for main PID values
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
for (let j = 0; j < 3; j++) {
|
for (let j = 0; j < 3; j++) {
|
||||||
FC.PIDS[j][i] = Math.min(Math.round(FC.PIDS[j][i] * this.MasterSliderValue), MAX_PID_GAIN);
|
FC.PIDS[j][i] = Math.min(Math.floor(FC.PIDS[j][i] * this.sliderMasterMultiplier), MAX_PID_GAIN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FC.ADVANCED_TUNING.feedforwardRoll = Math.min(Math.round(FC.ADVANCED_TUNING.feedforwardRoll * this.MasterSliderValue), MAX_FF_GAIN);
|
// ff
|
||||||
FC.ADVANCED_TUNING.feedforwardPitch = Math.min(Math.round(FC.ADVANCED_TUNING.feedforwardPitch * this.MasterSliderValue), MAX_FF_GAIN);
|
FC.ADVANCED_TUNING.feedforwardRoll = Math.min(Math.floor(this.PID_DEFAULT[4] * this.sliderFFGain * this.sliderMasterMultiplier), MAX_FF_GAIN);
|
||||||
FC.ADVANCED_TUNING.feedforwardYaw = Math.min(Math.round(FC.ADVANCED_TUNING.feedforwardYaw * this.MasterSliderValue), MAX_FF_GAIN);
|
FC.ADVANCED_TUNING.feedforwardPitch = Math.min(Math.floor(this.PID_DEFAULT[9] * this.sliderFFGain * this.sliderMasterMultiplier), MAX_FF_GAIN);
|
||||||
|
FC.ADVANCED_TUNING.feedforwardYaw = Math.min(Math.floor(this.PID_DEFAULT[14] * this.sliderFFGain * this.sliderMasterMultiplier), MAX_FF_GAIN);
|
||||||
if (this.dMinFeatureEnabled) {
|
if (this.dMinFeatureEnabled) {
|
||||||
FC.ADVANCED_TUNING.dMinRoll = Math.min(Math.round(FC.ADVANCED_TUNING.dMinRoll * this.MasterSliderValue), MAX_DMIN_GAIN);
|
FC.ADVANCED_TUNING.dMinRoll = Math.min(Math.floor(FC.ADVANCED_TUNING.dMinRoll * this.sliderMasterMultiplier), MAX_DMIN_GAIN);
|
||||||
FC.ADVANCED_TUNING.dMinPitch = Math.min(Math.round(FC.ADVANCED_TUNING.dMinPitch * this.MasterSliderValue), MAX_DMIN_GAIN);
|
FC.ADVANCED_TUNING.dMinPitch = Math.min(Math.floor(FC.ADVANCED_TUNING.dMinPitch * this.sliderMasterMultiplier), MAX_DMIN_GAIN);
|
||||||
FC.ADVANCED_TUNING.dMinYaw = Math.min(Math.round(FC.ADVANCED_TUNING.dMinYaw * this.MasterSliderValue), MAX_DMIN_GAIN);
|
FC.ADVANCED_TUNING.dMinYaw = Math.min(Math.floor(FC.ADVANCED_TUNING.dMinYaw * this.sliderMasterMultiplier), MAX_DMIN_GAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('output[name="tuningMasterSlider-number"]').val(this.MasterSliderValue);
|
this.updateFormPids();
|
||||||
$('output[name="tuningPDRatioSlider-number"]').val(this.PDRatioSliderValue);
|
|
||||||
$('output[name="tuningPDGainSlider-number"]').val(this.PDGainSliderValue);
|
|
||||||
$('output[name="tuningResponseSlider-number"]').val(this.ResponseSliderValue);
|
|
||||||
|
|
||||||
// updates values in forms
|
$('.pid_tuning input[name="dMinRoll"]').val(FC.ADVANCED_TUNING.dMinRoll);
|
||||||
FC.PID_NAMES.forEach(function(elementPid, indexPid) {
|
$('.pid_tuning input[name="dMinPitch"]').val(FC.ADVANCED_TUNING.dMinPitch);
|
||||||
let searchRow = $('.pid_tuning .' + elementPid + ' input');
|
$('.pid_tuning input[name="dMinYaw"]').val(FC.ADVANCED_TUNING.dMinYaw);
|
||||||
searchRow.each(function (indexInput) {
|
$('.pid_tuning .ROLL input[name="f"]').val(FC.ADVANCED_TUNING.feedforwardRoll);
|
||||||
if (indexPid < 3 && indexInput < 3) {
|
$('.pid_tuning .PITCH input[name="f"]').val(FC.ADVANCED_TUNING.feedforwardPitch);
|
||||||
$(this).val(FC.PIDS[indexPid][indexInput]);
|
$('.pid_tuning .YAW input[name="f"]').val(FC.ADVANCED_TUNING.feedforwardYaw);
|
||||||
|
};
|
||||||
|
|
||||||
|
TuningSliders.calculateNewPids = function() {
|
||||||
|
// this is the main calculation for PID sliders, inputs are in form of slider position values
|
||||||
|
// values get set both into forms and their respective variables
|
||||||
|
if (semver.lte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
this.legacyCalculateNewPids();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
$('output[name="sliderMasterMultiplier-number"]').val(this.sliderMasterMultiplier);
|
||||||
|
$('output[name="sliderRollPitchRatio-number"]').val(this.sliderRollPitchRatio);
|
||||||
|
$('output[name="sliderIGain-number"]').val(this.sliderIGain);
|
||||||
|
$('output[name="sliderPDRatio-number"]').val(this.sliderPDRatio);
|
||||||
|
$('output[name="sliderPDGain-number"]').val(this.sliderPDGain);
|
||||||
|
$('output[name="sliderDMinRatio-number"]').val(this.sliderDMinRatio);
|
||||||
|
$('output[name="sliderFFGain-number"]').val(this.sliderFFGain);
|
||||||
|
|
||||||
|
FC.TUNING_SLIDERS.slider_pids_mode = parseInt($('#sliderPidsModeSelect').val());
|
||||||
|
FC.TUNING_SLIDERS.slider_master_multiplier = TuningSliders.sliderMasterMultiplier * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_roll_pitch_ratio = TuningSliders.sliderRollPitchRatio * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_i_gain = TuningSliders.sliderIGain * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_pd_ratio = TuningSliders.sliderPDRatio * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_pd_gain = TuningSliders.sliderPDGain * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_dmin_ratio = TuningSliders.sliderDMinRatio * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_ff_gain = TuningSliders.sliderFFGain * 100;
|
||||||
|
|
||||||
|
FC.TUNING_SLIDERS.slider_dterm_filter = TuningSliders.sliderDTermFilter ? 1 : 0;
|
||||||
|
FC.TUNING_SLIDERS.slider_dterm_filter_multiplier = TuningSliders.sliderDTermFilterMultiplier * 100;
|
||||||
|
|
||||||
|
FC.TUNING_SLIDERS.slider_gyro_filter = TuningSliders.sliderGyroFilter ? 1 : 0;
|
||||||
|
FC.TUNING_SLIDERS.slider_gyro_filter_multiplier = TuningSliders.sliderGyroFilterMultiplier * 100;
|
||||||
|
|
||||||
|
MSP.promise(MSPCodes.MSP_SET_TUNING_SLIDERS, mspHelper.crunch(MSPCodes.MSP_SET_TUNING_SLIDERS));
|
||||||
|
MSP.send_message(MSPCodes.MSP_PID);
|
||||||
|
MSP.send_message(MSPCodes.MSP_PID_ADVANCED);
|
||||||
|
|
||||||
|
this.updateFormPids();
|
||||||
|
|
||||||
$('.pid_tuning input[name="dMinRoll"]').val(FC.ADVANCED_TUNING.dMinRoll);
|
$('.pid_tuning input[name="dMinRoll"]').val(FC.ADVANCED_TUNING.dMinRoll);
|
||||||
$('.pid_tuning input[name="dMinPitch"]').val(FC.ADVANCED_TUNING.dMinPitch);
|
$('.pid_tuning input[name="dMinPitch"]').val(FC.ADVANCED_TUNING.dMinPitch);
|
||||||
$('.pid_tuning input[name="dMinYaw"]').val(FC.ADVANCED_TUNING.dMinYaw);
|
$('.pid_tuning input[name="dMinYaw"]').val(FC.ADVANCED_TUNING.dMinYaw);
|
||||||
|
@ -322,9 +395,9 @@ TuningSliders.calculateNewPids = function() {
|
||||||
|
|
||||||
TuningSliders.calculateNewGyroFilters = function() {
|
TuningSliders.calculateNewGyroFilters = function() {
|
||||||
// calculate, set and display new values in forms based on slider position
|
// calculate, set and display new values in forms based on slider position
|
||||||
FC.FILTER_CONFIG.gyro_lowpass_dyn_min_hz = Math.round(this.FILTER_DEFAULT.gyro_lowpass_dyn_min_hz * this.gyroFilterSliderValue);
|
FC.FILTER_CONFIG.gyro_lowpass_dyn_min_hz = Math.floor(this.FILTER_DEFAULT.gyro_lowpass_dyn_min_hz * this.sliderGyroFilterMultiplier);
|
||||||
FC.FILTER_CONFIG.gyro_lowpass_dyn_max_hz = Math.round(this.FILTER_DEFAULT.gyro_lowpass_dyn_max_hz * this.gyroFilterSliderValue);
|
FC.FILTER_CONFIG.gyro_lowpass_dyn_max_hz = Math.floor(this.FILTER_DEFAULT.gyro_lowpass_dyn_max_hz * this.sliderGyroFilterMultiplier);
|
||||||
FC.FILTER_CONFIG.gyro_lowpass2_hz = Math.round(this.FILTER_DEFAULT.gyro_lowpass2_hz * this.gyroFilterSliderValue);
|
FC.FILTER_CONFIG.gyro_lowpass2_hz = Math.floor(this.FILTER_DEFAULT.gyro_lowpass2_hz * this.sliderGyroFilterMultiplier);
|
||||||
FC.FILTER_CONFIG.gyro_lowpass_type = this.FILTER_DEFAULT.gyro_lowpass_type;
|
FC.FILTER_CONFIG.gyro_lowpass_type = this.FILTER_DEFAULT.gyro_lowpass_type;
|
||||||
FC.FILTER_CONFIG.gyro_lowpass2_type = this.FILTER_DEFAULT.gyro_lowpass2_type;
|
FC.FILTER_CONFIG.gyro_lowpass2_type = this.FILTER_DEFAULT.gyro_lowpass2_type;
|
||||||
|
|
||||||
|
@ -333,14 +406,14 @@ TuningSliders.calculateNewGyroFilters = function() {
|
||||||
$('.pid_filter input[name="gyroLowpass2Frequency"]').val(FC.FILTER_CONFIG.gyro_lowpass2_hz);
|
$('.pid_filter input[name="gyroLowpass2Frequency"]').val(FC.FILTER_CONFIG.gyro_lowpass2_hz);
|
||||||
$('.pid_filter select[name="gyroLowpassDynType').val(FC.FILTER_CONFIG.gyro_lowpass_type);
|
$('.pid_filter select[name="gyroLowpassDynType').val(FC.FILTER_CONFIG.gyro_lowpass_type);
|
||||||
$('.pid_filter select[name="gyroLowpass2Type').val(FC.FILTER_CONFIG.gyro_lowpass2_type);
|
$('.pid_filter select[name="gyroLowpass2Type').val(FC.FILTER_CONFIG.gyro_lowpass2_type);
|
||||||
$('output[name="tuningGyroFilterSlider-number"]').val(this.gyroFilterSliderValue);
|
$('output[name="sliderGyroFilterMultiplier-number"]').val(this.sliderGyroFilterMultiplier);
|
||||||
};
|
};
|
||||||
|
|
||||||
TuningSliders.calculateNewDTermFilters = function() {
|
TuningSliders.calculateNewDTermFilters = function() {
|
||||||
// calculate, set and display new values in forms based on slider position
|
// calculate, set and display new values in forms based on slider position
|
||||||
FC.FILTER_CONFIG.dterm_lowpass_dyn_min_hz = Math.round(this.FILTER_DEFAULT.dterm_lowpass_dyn_min_hz * this.dtermFilterSliderValue);
|
FC.FILTER_CONFIG.dterm_lowpass_dyn_min_hz = Math.floor(this.FILTER_DEFAULT.dterm_lowpass_dyn_min_hz * this.sliderDTermFilterMultiplier);
|
||||||
FC.FILTER_CONFIG.dterm_lowpass_dyn_max_hz = Math.round(this.FILTER_DEFAULT.dterm_lowpass_dyn_max_hz * this.dtermFilterSliderValue);
|
FC.FILTER_CONFIG.dterm_lowpass_dyn_max_hz = Math.floor(this.FILTER_DEFAULT.dterm_lowpass_dyn_max_hz * this.sliderDTermFilterMultiplier);
|
||||||
FC.FILTER_CONFIG.dterm_lowpass2_hz = Math.round(this.FILTER_DEFAULT.dterm_lowpass2_hz * this.dtermFilterSliderValue);
|
FC.FILTER_CONFIG.dterm_lowpass2_hz = Math.floor(this.FILTER_DEFAULT.dterm_lowpass2_hz * this.sliderDTermFilterMultiplier);
|
||||||
FC.FILTER_CONFIG.dterm_lowpass_type = this.FILTER_DEFAULT.dterm_lowpass_type;
|
FC.FILTER_CONFIG.dterm_lowpass_type = this.FILTER_DEFAULT.dterm_lowpass_type;
|
||||||
FC.FILTER_CONFIG.dterm_lowpass2_type = this.FILTER_DEFAULT.dterm_lowpass2_type;
|
FC.FILTER_CONFIG.dterm_lowpass2_type = this.FILTER_DEFAULT.dterm_lowpass2_type;
|
||||||
|
|
||||||
|
@ -349,5 +422,5 @@ TuningSliders.calculateNewDTermFilters = function() {
|
||||||
$('.pid_filter input[name="dtermLowpass2Frequency"]').val(FC.FILTER_CONFIG.dterm_lowpass2_hz);
|
$('.pid_filter input[name="dtermLowpass2Frequency"]').val(FC.FILTER_CONFIG.dterm_lowpass2_hz);
|
||||||
$('.pid_filter select[name="dtermLowpassDynType').val(FC.FILTER_CONFIG.dterm_lowpass_type);
|
$('.pid_filter select[name="dtermLowpassDynType').val(FC.FILTER_CONFIG.dterm_lowpass_type);
|
||||||
$('.pid_filter select[name="dtermLowpass2Type').val(FC.FILTER_CONFIG.dterm_lowpass2_type);
|
$('.pid_filter select[name="dtermLowpass2Type').val(FC.FILTER_CONFIG.dterm_lowpass2_type);
|
||||||
$('output[name="tuningDTermFilterSlider-number"]').val(this.dtermFilterSliderValue);
|
$('output[name="sliderDTermFilterMultiplier-number"]').val(this.sliderDTermFilterMultiplier);
|
||||||
};
|
};
|
||||||
|
|
16
src/js/fc.js
16
src/js/fc.js
|
@ -148,6 +148,7 @@ const FC = {
|
||||||
SERVO_DATA: null,
|
SERVO_DATA: null,
|
||||||
SERVO_RULES: null,
|
SERVO_RULES: null,
|
||||||
TRANSPONDER: null,
|
TRANSPONDER: null,
|
||||||
|
TUNING_SLIDERS: null,
|
||||||
VOLTAGE_METERS: null,
|
VOLTAGE_METERS: null,
|
||||||
VOLTAGE_METER_CONFIGS: null,
|
VOLTAGE_METER_CONFIGS: null,
|
||||||
VTXTABLE_BAND: null,
|
VTXTABLE_BAND: null,
|
||||||
|
@ -648,6 +649,21 @@ const FC = {
|
||||||
];
|
];
|
||||||
|
|
||||||
this.VTX_DEVICE_STATUS = null;
|
this.VTX_DEVICE_STATUS = null;
|
||||||
|
|
||||||
|
this.TUNING_SLIDERS = {
|
||||||
|
slider_pids_mode: 0,
|
||||||
|
slider_master_multiplier: 0,
|
||||||
|
slider_roll_pitch_ratio: 0,
|
||||||
|
slider_i_gain: 0,
|
||||||
|
slider_pd_ratio: 0,
|
||||||
|
slider_pd_gain: 0,
|
||||||
|
slider_dmin_ratio: 0,
|
||||||
|
slider_ff_gain: 0,
|
||||||
|
slider_dterm_filter: 0,
|
||||||
|
slider_dterm_filter_multiplier: 0,
|
||||||
|
slider_gyro_filter: 0,
|
||||||
|
slider_gyro_filter_multiplier: 0,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getSerialRxTypes: () => {
|
getSerialRxTypes: () => {
|
||||||
|
|
|
@ -502,6 +502,8 @@ function startProcess() {
|
||||||
if (FC.FEATURE_CONFIG && FC.FEATURE_CONFIG.features !== 0) {
|
if (FC.FEATURE_CONFIG && FC.FEATURE_CONFIG.features !== 0) {
|
||||||
updateTabList(FC.FEATURE_CONFIG.features);
|
updateTabList(FC.FEATURE_CONFIG.features);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TuningSliders.setExpertMode(checked);
|
||||||
}).change();
|
}).change();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,9 @@ const MSPCodes = {
|
||||||
|
|
||||||
MSP_MOTOR_TELEMETRY: 139,
|
MSP_MOTOR_TELEMETRY: 139,
|
||||||
|
|
||||||
|
MSP_TUNING_SLIDERS: 140,
|
||||||
|
MSP_SET_TUNING_SLIDERS: 141,
|
||||||
|
|
||||||
MSP_STATUS_EX: 150,
|
MSP_STATUS_EX: 150,
|
||||||
|
|
||||||
MSP_UID: 160,
|
MSP_UID: 160,
|
||||||
|
|
|
@ -1475,6 +1475,26 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSPCodes.MSP_SET_TUNING_SLIDERS:
|
||||||
|
console.log("Tuning Sliders data sent");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MSPCodes.MSP_TUNING_SLIDERS:
|
||||||
|
FC.TUNING_SLIDERS.slider_pids_mode = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_master_multiplier = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_roll_pitch_ratio = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_i_gain = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_pd_ratio = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_pd_gain = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_dmin_ratio = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_ff_gain = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_dterm_filter = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_dterm_filter_multiplier = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_gyro_filter = data.readU8();
|
||||||
|
FC.TUNING_SLIDERS.slider_gyro_filter_multiplier = data.readU8();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case MSPCodes.MSP_SET_VTXTABLE_POWERLEVEL:
|
case MSPCodes.MSP_SET_VTXTABLE_POWERLEVEL:
|
||||||
console.log("VTX powerlevel sent");
|
console.log("VTX powerlevel sent");
|
||||||
break;
|
break;
|
||||||
|
@ -2274,6 +2294,22 @@ MspHelper.prototype.crunch = function(code) {
|
||||||
buffer.push8(1);
|
buffer.push8(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MSPCodes.MSP_SET_TUNING_SLIDERS:
|
||||||
|
buffer.push8(FC.TUNING_SLIDERS.slider_pids_mode)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_master_multiplier)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_roll_pitch_ratio)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_i_gain)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_pd_ratio)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_pd_gain)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_dmin_ratio)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_ff_gain)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_dterm_filter)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_dterm_filter_multiplier)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_gyro_filter)
|
||||||
|
.push8(FC.TUNING_SLIDERS.slider_gyro_filter_multiplier);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,13 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
return MSP.promise(MSPCodes.MSP_RC_DEADBAND);
|
return MSP.promise(MSPCodes.MSP_RC_DEADBAND);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return MSP.promise(MSPCodes.MSP_MOTOR_CONFIG);
|
return MSP.promise(MSPCodes.MSP_MOTOR_CONFIG);
|
||||||
|
}).then(function() {
|
||||||
|
let promise;
|
||||||
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
promise = MSP.promise(MSPCodes.MSP_TUNING_SLIDERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
return promise;
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_html);
|
MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_html);
|
||||||
});
|
});
|
||||||
|
@ -973,6 +980,23 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
FC.ADVANCED_TUNING.vbat_sag_compensation = $('input[id="vbatSagCompensation"]').is(':checked') ? parseInt($('input[name="vbatSagValue"]').val()) : 0;
|
FC.ADVANCED_TUNING.vbat_sag_compensation = $('input[id="vbatSagCompensation"]').is(':checked') ? parseInt($('input[name="vbatSagValue"]').val()) : 0;
|
||||||
FC.ADVANCED_TUNING.thrustLinearization = $('input[id="thrustLinearization"]').is(':checked') ? parseInt($('input[name="thrustLinearValue"]').val()) : 0;
|
FC.ADVANCED_TUNING.thrustLinearization = $('input[id="thrustLinearization"]').is(':checked') ? parseInt($('input[name="thrustLinearValue"]').val()) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
FC.TUNING_SLIDERS.slider_pids_mode = parseInt($('#sliderPidsModeSelect').val());
|
||||||
|
FC.TUNING_SLIDERS.slider_master_multiplier = TuningSliders.sliderMasterMultiplier * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_roll_pitch_ratio = TuningSliders.sliderRollPitchRatio * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_i_gain = TuningSliders.sliderIGain * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_pd_ratio = TuningSliders.sliderPDRatio * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_pd_gain = TuningSliders.sliderPDGain * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_dmin_ratio = TuningSliders.sliderDMinRatio * 100;
|
||||||
|
FC.TUNING_SLIDERS.slider_ff_gain = TuningSliders.sliderFFGain * 100;
|
||||||
|
|
||||||
|
FC.TUNING_SLIDERS.slider_dterm_filter = TuningSliders.sliderDTermFilter ? 1 : 0;
|
||||||
|
FC.TUNING_SLIDERS.slider_dterm_filter_multiplier = TuningSliders.sliderDTermFilterMultiplier * 100;
|
||||||
|
|
||||||
|
FC.TUNING_SLIDERS.slider_gyro_filter = TuningSliders.sliderGyroFilter ? 1 : 0;
|
||||||
|
FC.TUNING_SLIDERS.slider_gyro_filter_multiplier = TuningSliders.sliderGyroFilterMultiplier * 100;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAllPids() {
|
function showAllPids() {
|
||||||
|
@ -1774,41 +1798,23 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
const NON_EXPERT_SLIDER_MAX = 1.25;
|
const NON_EXPERT_SLIDER_MAX = 1.25;
|
||||||
const NON_EXPERT_SLIDER_MIN = 0.7;
|
const NON_EXPERT_SLIDER_MIN = 0.7;
|
||||||
|
|
||||||
$('input[name="expertModeCheckbox"]').change(function() {
|
const SLIDER_STEP_LOWER = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43) ? 0.005 : 0.05;
|
||||||
if (TuningSliders.expertMode !== $(this).is(':checked')) {
|
const SLIDER_STEP_UPPER = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43) ? 0.01 : 0.1;
|
||||||
TuningSliders.setExpertMode($(this).is(':checked'));
|
|
||||||
TuningSliders.updatePidSlidersDisplay();
|
$('#sliderPidsModeSelect').val(FC.TUNING_SLIDERS.slider_pids_mode);
|
||||||
TuningSliders.updateFilterSlidersDisplay();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#dMinSwitch').change(function() {
|
|
||||||
TuningSliders.setDMinFeatureEnabled($(this).is(':checked'));
|
|
||||||
// switch dmin and dmax values on dmin on/off if sliders available
|
|
||||||
if (!TuningSliders.pidSlidersUnavailable) {
|
|
||||||
if (TuningSliders.dMinFeatureEnabled) {
|
|
||||||
FC.ADVANCED_TUNING.dMinRoll = FC.PIDS[0][2];
|
|
||||||
FC.ADVANCED_TUNING.dMinPitch = FC.PIDS[1][2];
|
|
||||||
FC.ADVANCED_TUNING.dMinYaw = FC.PIDS[2][2];
|
|
||||||
} else {
|
|
||||||
FC.PIDS[0][2] = FC.ADVANCED_TUNING.dMinRoll;
|
|
||||||
FC.PIDS[1][2] = FC.ADVANCED_TUNING.dMinPitch;
|
|
||||||
FC.PIDS[2][2] = FC.ADVANCED_TUNING.dMinYaw;
|
|
||||||
}
|
|
||||||
TuningSliders.calculateNewPids();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// integrated yaw doesn't work with sliders therefore sliders are disabled
|
// integrated yaw doesn't work with sliders therefore sliders are disabled
|
||||||
$('input[id="useIntegratedYaw"]').change(() => TuningSliders.updatePidSlidersDisplay());
|
$('input[id="useIntegratedYaw"]').change(() => TuningSliders.updatePidSlidersDisplay());
|
||||||
|
|
||||||
// pid sliders inputs
|
const allPidTuningSliders = $('#sliderMasterMultiplier, #sliderRollPitchRatio, #sliderIGain, #sliderPDRatio, #sliderPDGain, #sliderDMinRatio, #sliderFFGain');
|
||||||
$('#tuningMasterSlider, #tuningPDRatioSlider, #tuningPDGainSlider, #tuningResponseSlider').on('input', function() {
|
|
||||||
|
allPidTuningSliders.on('input', function() {
|
||||||
const slider = $(this);
|
const slider = $(this);
|
||||||
// adjust step for more smoothness above 1x
|
// adjust step for more smoothness above 1x
|
||||||
if (slider.val() >= 1) {
|
if (slider.val() >= 1) {
|
||||||
slider.attr('step', 0.05);
|
slider.attr('step', SLIDER_STEP_LOWER);
|
||||||
} else {
|
} else {
|
||||||
slider.attr('step', 0.1);
|
slider.attr('step', SLIDER_STEP_UPPER);
|
||||||
}
|
}
|
||||||
if (!TuningSliders.expertMode) {
|
if (!TuningSliders.expertMode) {
|
||||||
if (slider.val() > NON_EXPERT_SLIDER_MAX) {
|
if (slider.val() > NON_EXPERT_SLIDER_MAX) {
|
||||||
|
@ -1818,28 +1824,25 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const scaledValue = TuningSliders.scaleSliderValue(slider.val());
|
const scaledValue = TuningSliders.scaleSliderValue(slider.val());
|
||||||
if (slider.is('#tuningMasterSlider')) {
|
if (slider.is('#sliderMasterMultiplier')) {
|
||||||
TuningSliders.MasterSliderValue = scaledValue;
|
TuningSliders.sliderMasterMultiplier = scaledValue;
|
||||||
} else if (slider.is('#tuningPDRatioSlider')) {
|
} else if (slider.is('#sliderRollPitchRatio')) {
|
||||||
TuningSliders.PDRatioSliderValue = scaledValue;
|
TuningSliders.sliderRollPitchRatio = scaledValue;
|
||||||
} else if (slider.is('#tuningPDGainSlider')) {
|
} else if (slider.is('#sliderIGain')) {
|
||||||
TuningSliders.PDGainSliderValue = scaledValue;
|
TuningSliders.sliderIGain = scaledValue;
|
||||||
} else if (slider.is('#tuningResponseSlider')) {
|
} else if (slider.is('#sliderPDRatio')) {
|
||||||
TuningSliders.ResponseSliderValue = scaledValue;
|
TuningSliders.sliderPDRatio = scaledValue;
|
||||||
|
} else if (slider.is('#sliderPDGain')) {
|
||||||
|
TuningSliders.sliderPDGain = scaledValue;
|
||||||
|
} else if (slider.is('#sliderDMinRatio')) {
|
||||||
|
TuningSliders.sliderDMinRatio = scaledValue;
|
||||||
|
} else if (slider.is('#sliderFFGain')) {
|
||||||
|
TuningSliders.sliderFFGain = scaledValue;
|
||||||
}
|
}
|
||||||
TuningSliders.calculateNewPids();
|
TuningSliders.calculateNewPids();
|
||||||
self.analyticsChanges['PidTuningSliders'] = "On";
|
self.analyticsChanges['PidTuningSliders'] = "On";
|
||||||
});
|
});
|
||||||
$('#tuningMasterSlider, #tuningPDRatioSlider, #tuningPDGainSlider, #tuningResponseSlider').mousedown(function() {
|
allPidTuningSliders.mouseup(function() {
|
||||||
// adjust step for more smoothness above 1x on mousedown
|
|
||||||
const slider = $(this);
|
|
||||||
if (slider.val() >= 1) {
|
|
||||||
slider.attr('step', 0.05);
|
|
||||||
} else {
|
|
||||||
slider.attr('step', 0.1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$('#tuningMasterSlider, #tuningPDRatioSlider, #tuningPDGainSlider, #tuningResponseSlider').mouseup(function() {
|
|
||||||
// readjust dmin maximums
|
// readjust dmin maximums
|
||||||
$('.pid_tuning .ROLL input[name="d"]').change();
|
$('.pid_tuning .ROLL input[name="d"]').change();
|
||||||
$('.pid_tuning .PITCH input[name="d"]').change();
|
$('.pid_tuning .PITCH input[name="d"]').change();
|
||||||
|
@ -1847,17 +1850,23 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
TuningSliders.updatePidSlidersDisplay();
|
TuningSliders.updatePidSlidersDisplay();
|
||||||
});
|
});
|
||||||
// reset to middle with double click
|
// reset to middle with double click
|
||||||
$('#tuningMasterSlider, #tuningPDRatioSlider, #tuningPDGainSlider, #tuningResponseSlider').dblclick(function() {
|
allPidTuningSliders.dblclick(function() {
|
||||||
const slider = $(this);
|
const slider = $(this);
|
||||||
slider.val(1);
|
slider.val(1);
|
||||||
if (slider.is('#tuningMasterSlider')) {
|
if (slider.is('#sliderMasterMultiplier')) {
|
||||||
TuningSliders.MasterSliderValue = 1;
|
TuningSliders.sliderMasterMultiplier = 1;
|
||||||
} else if (slider.is('#tuningPDRatioSlider')) {
|
} else if (slider.is('#sliderRollPitchRatio')) {
|
||||||
TuningSliders.PDRatioSliderValue = 1;
|
TuningSliders.sliderRollPitchRatio = 1;
|
||||||
} else if (slider.is('#tuningPDGainSlider')) {
|
} else if (slider.is('#sliderIGain')) {
|
||||||
TuningSliders.PDGainSliderValue = 1;
|
TuningSliders.sliderIGain = 1;
|
||||||
} else if (slider.is('#tuningResponseSlider')) {
|
} else if (slider.is('#sliderPDRatio')) {
|
||||||
TuningSliders.ResponseSliderValue = 1;
|
TuningSliders.sliderPDRatio = 1;
|
||||||
|
} else if (slider.is('#sliderPDGain')) {
|
||||||
|
TuningSliders.sliderPDGain = 1;
|
||||||
|
} else if (slider.is('#sliderDMinRatio')) {
|
||||||
|
TuningSliders.sliderDMinRatio = 1;
|
||||||
|
} else if (slider.is('#sliderFFGain')) {
|
||||||
|
TuningSliders.sliderFFGain = 1;
|
||||||
}
|
}
|
||||||
TuningSliders.calculateNewPids();
|
TuningSliders.calculateNewPids();
|
||||||
TuningSliders.updatePidSlidersDisplay();
|
TuningSliders.updatePidSlidersDisplay();
|
||||||
|
@ -1874,8 +1883,15 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// filter slider inputs
|
// filter slider inputs
|
||||||
$('#tuningGyroFilterSlider, #tuningDTermFilterSlider').on('input', function() {
|
const allFilterTuningSliders = $('#sliderGyroFilterMultiplier, #sliderDTermFilterMultiplier');
|
||||||
|
allFilterTuningSliders.on('input', function() {
|
||||||
const slider = $(this);
|
const slider = $(this);
|
||||||
|
// adjust step for more smoothness above 1x
|
||||||
|
if (slider.val() >= 1) {
|
||||||
|
slider.attr('step', SLIDER_STEP_LOWER);
|
||||||
|
} else {
|
||||||
|
slider.attr('step', SLIDER_STEP_UPPER);
|
||||||
|
}
|
||||||
if (!TuningSliders.expertMode) {
|
if (!TuningSliders.expertMode) {
|
||||||
if (slider.val() > NON_EXPERT_SLIDER_MAX) {
|
if (slider.val() > NON_EXPERT_SLIDER_MAX) {
|
||||||
slider.val(NON_EXPERT_SLIDER_MAX);
|
slider.val(NON_EXPERT_SLIDER_MAX);
|
||||||
|
@ -1884,35 +1900,35 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const scaledValue = TuningSliders.scaleSliderValue(slider.val());
|
const scaledValue = TuningSliders.scaleSliderValue(slider.val());
|
||||||
if (slider.is('#tuningGyroFilterSlider')) {
|
if (slider.is('#sliderGyroFilterMultiplier')) {
|
||||||
TuningSliders.gyroFilterSliderValue = scaledValue;
|
TuningSliders.sliderGyroFilterMultiplier = scaledValue;
|
||||||
TuningSliders.calculateNewGyroFilters();
|
TuningSliders.calculateNewGyroFilters();
|
||||||
self.analyticsChanges['GyroFilterTuningSlider'] = "On";
|
self.analyticsChanges['GyroFilterTuningSlider'] = "On";
|
||||||
} else if (slider.is('#tuningDTermFilterSlider')) {
|
} else if (slider.is('#sliderDTermFilterMultiplier')) {
|
||||||
TuningSliders.dtermFilterSliderValue = scaledValue;
|
TuningSliders.sliderDTermFilterMultiplier = scaledValue;
|
||||||
TuningSliders.calculateNewDTermFilters();
|
TuningSliders.calculateNewDTermFilters();
|
||||||
self.analyticsChanges['DTermFilterTuningSlider'] = "On";
|
self.analyticsChanges['DTermFilterTuningSlider'] = "On";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#tuningGyroFilterSlider, #tuningDTermFilterSlider').mouseup(function() {
|
allFilterTuningSliders.mouseup(function() {
|
||||||
TuningSliders.updateFilterSlidersDisplay();
|
TuningSliders.updateFilterSlidersDisplay();
|
||||||
});
|
});
|
||||||
// reset to middle with double click
|
// reset to middle with double click
|
||||||
$('#tuningGyroFilterSlider, #tuningDTermFilterSlider').dblclick(function() {
|
allFilterTuningSliders.dblclick(function() {
|
||||||
const slider = $(this);
|
const slider = $(this);
|
||||||
slider.val(1);
|
slider.val(1);
|
||||||
if (slider.is('#tuningGyroFilterSlider')) {
|
if (slider.is('#sliderGyroFilterMultiplier')) {
|
||||||
TuningSliders.gyroFilterSliderValue = 1;
|
TuningSliders.sliderGyroFilterMultiplier = 1;
|
||||||
TuningSliders.calculateNewGyroFilters();
|
TuningSliders.calculateNewGyroFilters();
|
||||||
} else if (slider.is('#tuningDTermFilterSlider')) {
|
} else if (slider.is('#sliderDTermFilterMultiplier')) {
|
||||||
TuningSliders.dtermFilterSliderValue = 1;
|
TuningSliders.sliderDTermFilterMultiplier = 1;
|
||||||
TuningSliders.calculateNewDTermFilters();
|
TuningSliders.calculateNewDTermFilters();
|
||||||
}
|
}
|
||||||
TuningSliders.updateFilterSlidersDisplay();
|
TuningSliders.updateFilterSlidersDisplay();
|
||||||
});
|
});
|
||||||
// enable PID sliders button
|
// enable PID sliders button
|
||||||
$('a.buttonFilterTuningSliders').click(function() {
|
$('a.buttonFilterTuningSliders').click(function() {
|
||||||
if (TuningSliders.filterGyroSliderUnavailable) {
|
if (TuningSliders.sliderGyroFilter) {
|
||||||
// update switchery dynamically based on defaults
|
// update switchery dynamically based on defaults
|
||||||
$('input[id="gyroLowpassDynEnabled"]').prop('checked', false).click();
|
$('input[id="gyroLowpassDynEnabled"]').prop('checked', false).click();
|
||||||
$('input[id="gyroLowpassEnabled"]').prop('checked', true).click();
|
$('input[id="gyroLowpassEnabled"]').prop('checked', true).click();
|
||||||
|
@ -1920,7 +1936,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
TuningSliders.resetGyroFilterSlider();
|
TuningSliders.resetGyroFilterSlider();
|
||||||
self.analyticsChanges['GyroFilterTuningSlider'] = "On";
|
self.analyticsChanges['GyroFilterTuningSlider'] = "On";
|
||||||
}
|
}
|
||||||
if (TuningSliders.filterDTermSliderUnavailable) {
|
if (TuningSliders.sliderDTermFilter) {
|
||||||
$('input[id="dtermLowpassDynEnabled"]').prop('checked', false).click();
|
$('input[id="dtermLowpassDynEnabled"]').prop('checked', false).click();
|
||||||
$('input[id="dtermLowpassEnabled"]').prop('checked', true).click();
|
$('input[id="dtermLowpassEnabled"]').prop('checked', true).click();
|
||||||
$('input[id="dtermLowpass2Enabled"]').prop('checked', false).click();
|
$('input[id="dtermLowpass2Enabled"]').prop('checked', false).click();
|
||||||
|
@ -1937,10 +1953,10 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
// update on filter value or type changes
|
// update on filter value or type changes
|
||||||
$('.pid_filter tr:not(.newFilter) input, .pid_filter tr:not(.newFilter) select').on('input', function() {
|
$('.pid_filter tr:not(.newFilter) input, .pid_filter tr:not(.newFilter) select').on('input', function() {
|
||||||
TuningSliders.updateFilterSlidersDisplay();
|
TuningSliders.updateFilterSlidersDisplay();
|
||||||
if (TuningSliders.filterGyroSliderUnavailable) {
|
if (TuningSliders.sliderGyroFilter) {
|
||||||
self.analyticsChanges['GyroFilterTuningSlider'] = "Off";
|
self.analyticsChanges['GyroFilterTuningSlider'] = "Off";
|
||||||
}
|
}
|
||||||
if (TuningSliders.filterDTermSliderUnavailable) {
|
if (TuningSliders.sliderDTermFilter) {
|
||||||
self.analyticsChanges['DTermFilterTuningSlider'] = "Off";
|
self.analyticsChanges['DTermFilterTuningSlider'] = "Off";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1997,6 +2013,13 @@ TABS.pid_tuning.initialize = function (callback) {
|
||||||
return MSP.promise(MSPCodes.MSP_SET_RC_TUNING, mspHelper.crunch(MSPCodes.MSP_SET_RC_TUNING));
|
return MSP.promise(MSPCodes.MSP_SET_RC_TUNING, mspHelper.crunch(MSPCodes.MSP_SET_RC_TUNING));
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG));
|
return MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG));
|
||||||
|
}).then(function () {
|
||||||
|
let promise;
|
||||||
|
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
|
||||||
|
promise = MSP.promise(MSPCodes.MSP_SET_TUNING_SLIDERS, mspHelper.crunch(MSPCodes.MSP_SET_TUNING_SLIDERS));
|
||||||
|
}
|
||||||
|
|
||||||
|
return promise;
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
|
return MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
|
|
|
@ -169,10 +169,16 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- TUNING SLIDERS-->
|
<!-- TUNING SLIDERS-->
|
||||||
<div class="gui_box grey topspacer tuningPIDSliders">
|
<div id="slidersPidsBox" class="gui_box grey topspacer tuningPIDSliders">
|
||||||
<table class="pid_titlebar">
|
<table class="pid_titlebar">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="sm-min"></th>
|
<th scope="col" class="sm-min">
|
||||||
|
<select id="sliderPidsModeSelect">
|
||||||
|
<option value="0">OFF</option>
|
||||||
|
<option value="1">RP</option>
|
||||||
|
<option value="2">RPY</option>
|
||||||
|
<select>
|
||||||
|
</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th i18n="pidTuningSliderLow"></th>
|
<th i18n="pidTuningSliderLow"></th>
|
||||||
<th i18n="pidTuningSliderDefault"></th>
|
<th i18n="pidTuningSliderDefault"></th>
|
||||||
|
@ -193,10 +199,10 @@
|
||||||
<span i18n="pidTuningMasterSlider"></span>
|
<span i18n="pidTuningMasterSlider"></span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<output type="number" name="tuningMasterSlider-number"></output>
|
<output type="number" name="sliderMasterMultiplier-number"></output>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="tuningMasterSlider" />
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderMasterMultiplier" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="helpicon cf_tip" i18n_title="pidTuningMasterSliderHelp"></div>
|
<div class="helpicon cf_tip" i18n_title="pidTuningMasterSliderHelp"></div>
|
||||||
|
@ -209,13 +215,41 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="sm-min">
|
<td class="sm-min">
|
||||||
<span i18n="pidTuningPDRatioSlider"></span>
|
<span i18n="pidTuningRollPitchRatioSlider"/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<output type="number" name="tuningPDRatioSlider-number"></output>
|
<output type="number" name="sliderRollPitchRatio-number"></output>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="tuningPDRatioSlider" />
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderRollPitchRatio" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="helpicon cf_tip" i18n_title="pidTuningRollPitchRatioSliderHelp"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span i18n="pidTuningIGainSlider"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<output type="number" name="sliderIGain-number"></output>
|
||||||
|
</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderIGain" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="helpicon cf_tip" i18n_title="pidTuningIGainSliderHelp"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span i18n="pidTuningPDRatioSlider"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<output type="number" name="sliderPDRatio-number"></output>
|
||||||
|
</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderPDRatio" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="helpicon cf_tip" i18n_title="pidTuningPDRatioSliderHelp"></div>
|
<div class="helpicon cf_tip" i18n_title="pidTuningPDRatioSliderHelp"></div>
|
||||||
|
@ -231,10 +265,10 @@
|
||||||
<span i18n="pidTuningPDGainSlider"></span>
|
<span i18n="pidTuningPDGainSlider"></span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<output type="number" name="tuningPDGainSlider-number"></output>
|
<output type="number" name="sliderPDGain-number"></output>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="tuningPDGainSlider" />
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderPDGain" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="helpicon cf_tip" i18n_title="pidTuningPDGainSliderHelp"></div>
|
<div class="helpicon cf_tip" i18n_title="pidTuningPDGainSliderHelp"></div>
|
||||||
|
@ -247,13 +281,27 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="sm-min">
|
<td class="sm-min">
|
||||||
<span i18n="pidTuningResponseSlider"></span>
|
<span i18n="pidTuningDMinRatioSlider"/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<output type="number" name="tuningResponseSlider-number"></output>
|
<output type="number" name="sliderDMinRatio-number"></output>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="tuningResponseSlider" />
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderDMinRatio" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="helpicon cf_tip" i18n_title="pidTuningDMinRatioSliderHelp"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span i18n="pidTuningResponseSlider"/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<output type="number" name="sliderFFGain-number"></output>
|
||||||
|
</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderFFGain" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="helpicon cf_tip" i18n_title="pidTuningResponseSliderHelp"></div>
|
<div class="helpicon cf_tip" i18n_title="pidTuningResponseSliderHelp"></div>
|
||||||
|
@ -1016,7 +1064,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Filter Slider -->
|
<!-- Filter Slider -->
|
||||||
<div class="gui_box grey topspacer tuningFilterSliders">
|
<div id="slidersFilterBox"class="gui_box grey topspacer tuningFilterSliders">
|
||||||
<table class="pid_titlebar">
|
<table class="pid_titlebar">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="sm-min"></th>
|
<th scope="col" class="sm-min"></th>
|
||||||
|
@ -1040,10 +1088,10 @@
|
||||||
<span i18n="pidTuningGyroFilterSlider"></span>
|
<span i18n="pidTuningGyroFilterSlider"></span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<output type="number" name="tuningGyroFilterSlider-number"></output>
|
<output type="number" name="sliderGyroFilterMultiplier-number"></output>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="tuningGyroFilterSlider" />
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderGyroFilterMultiplier" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="helpicon cf_tip" i18n_title="pidTuningGyroFilterSliderHelp"></div>
|
<div class="helpicon cf_tip" i18n_title="pidTuningGyroFilterSliderHelp"></div>
|
||||||
|
@ -1059,10 +1107,10 @@
|
||||||
<span i18n="pidTuningDTermFilterSlider"></span>
|
<span i18n="pidTuningDTermFilterSlider"></span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<output type="number" name="tuningDTermFilterSlider-number"></output>
|
<output type="number" name="sliderDTermFilterMultiplier-number"></output>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="tuningDTermFilterSlider" />
|
<input type="range" min="0.5" max="1.5" step="0.05" class="tuningSlider" id="sliderDTermFilterMultiplier" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="helpicon cf_tip" i18n_title="pidTuningDTermFilterSliderHelp"></div>
|
<div class="helpicon cf_tip" i18n_title="pidTuningDTermFilterSliderHelp"></div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue