1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-19 14:25:14 +03:00

Tuning sliders non expert mode limits

This commit is contained in:
IvoFPV 2019-09-12 19:23:54 +02:00
parent e85bf0c073
commit 8b7f0353e5
6 changed files with 106 additions and 58 deletions

View file

@ -3222,8 +3222,8 @@
"message": "Sliders to adjust the quad flight characteristics (PID gains)<br><br>Master Multiplier: Raises or Lowers all the PID gains (above) holding the proportional difference between the gains.<br><br>PD Balance: Adjusts the balance (ratio \\ proportional difference) between the P and D terms ('the spring' [p-term] and 'shock absorber' [d-term]).<br><br>PD Gain: Raises or Lowers the P&D gains together - holding the ratio (balance) between the two - for more (or less) PID control authority.<br><br>Stick Response Gain: Raises or Lowers the FeedForward gains to control the stick response feel of the quad.", "message": "Sliders to adjust the quad flight characteristics (PID gains)<br><br>Master Multiplier: Raises or Lowers all the PID gains (above) holding the proportional difference between the gains.<br><br>PD Balance: Adjusts the balance (ratio \\ proportional difference) between the P and D terms ('the spring' [p-term] and 'shock absorber' [d-term]).<br><br>PD Gain: Raises or Lowers the P&D gains together - holding the ratio (balance) between the two - for more (or less) PID control authority.<br><br>Stick Response Gain: Raises or Lowers the FeedForward gains to control the stick response feel of the quad.",
"description": "Overall helpicon message for PID tuning sliders" "description": "Overall helpicon message for PID tuning sliders"
}, },
"pidTuningSliderHighWarning": { "pidTuningSliderWarning": {
"message": "<span class=\"message-negative\">CAUTION</span>: Pushing sliders this high may cause flyaways, motor damage or unsafe craft behaviour. Please proceed with caution.", "message": "<span class=\"message-negative\">CAUTION</span>: Current slider positions may cause flyaways, motor damage or unsafe craft behaviour. Please proceed with caution.",
"description": "Warning shown when tuning slider are above safe limits" "description": "Warning shown when tuning slider are above safe limits"
}, },
"pidTuningSlidersDisabled": { "pidTuningSlidersDisabled": {
@ -3234,6 +3234,10 @@
"message": "Enable Sliders", "message": "Enable Sliders",
"description": "Button label for enabling sliders" "description": "Button label for enabling sliders"
}, },
"pidTuningSlidersNonExpertMode": {
"message": "<strong>Note:</strong> Sliders range is restricted because you are not in expert mode. This range should be suitable for most builds and beginners.",
"description": "Sliders restricted message"
},
"pidTuningSliderLow": { "pidTuningSliderLow": {
"message": "Low", "message": "Low",
"description": "Tuning Slider Low header" "description": "Tuning Slider Low header"

View file

@ -154,7 +154,6 @@
border-bottom: 1px solid #6b6b6b; border-bottom: 1px solid #6b6b6b;
} }
.tab-pid_tuning .slidersHighWarning, .tab-pid_tuning .slidersWarning {
.tab-pid_tuning .slidersFilterHighWarning {
background: #542415; background: #542415;
} }

View file

@ -751,7 +751,7 @@
opacity: 0.8; opacity: 0.8;
transition: opacity .2s; transition: opacity .2s;
margin: 7px; margin: 7px;
background: none; background: var(--boxBackground);
} }
.tab-pid_tuning .tuningSlider:hover { .tab-pid_tuning .tuningSlider:hover {
@ -766,6 +766,13 @@
height: 15px; height: 15px;
} }
.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-size: 55%;
background-position: 44%;
background-repeat: no-repeat;
}
.tab-pid_tuning .tuningSlider::-webkit-slider-thumb { .tab-pid_tuning .tuningSlider::-webkit-slider-thumb {
-webkit-appearance: none; -webkit-appearance: none;
width: 23px; width: 23px;
@ -830,14 +837,19 @@
width: 30px; width: 30px;
} }
.tab-pid_tuning .slidersHighWarning, .tab-pid_tuning .slidersWarning {
.tab-pid_tuning .slidersFilterHighWarning { background: #ffa3a3;
background: #ffb3b3;
border: 1px solid red; border: 1px solid red;
font-weight: 600; font-weight: 600;
font-size: 12px; font-size: 12px;
} }
.tab-pid_tuning .nonExpertModeSlidersNote {
text-align: center;
padding-top: 2px;
padding-bottom: 2px;
}
.tab-pid_tuning .note-button td:nth-child(n) { .tab-pid_tuning .note-button td:nth-child(n) {
padding-left: 7px; padding-left: 7px;
padding-right: 7px; padding-right: 7px;

View file

@ -20,6 +20,8 @@ var TuningSliders = {
cachedPidSliderValues: false, cachedPidSliderValues: false,
cachedGyroSliderValues: false, cachedGyroSliderValues: false,
cachedDTermSliderValues: false, cachedDTermSliderValues: false,
expertMode: false,
}; };
TuningSliders.initialize = function() { TuningSliders.initialize = function() {
@ -27,6 +29,7 @@ TuningSliders.initialize = function() {
this.FILTER_DEFAULT = FC.getFilterDefaults(); this.FILTER_DEFAULT = FC.getFilterDefaults();
this.setDMinFeatureEnabled($('#dMinSwitch').is(':checked')); this.setDMinFeatureEnabled($('#dMinSwitch').is(':checked'));
this.setExpertMode($('input[name="expertModeCheckbox"]').is(':checked'));
this.initPidSlidersPosition(); this.initPidSlidersPosition();
this.initGyroFilterSliderPosition(); this.initGyroFilterSliderPosition();
@ -50,6 +53,17 @@ TuningSliders.setDMinFeatureEnabled = function(dMinFeatureEnabled) {
} }
}; };
TuningSliders.setExpertMode = function(expertMode) {
this.expertMode = expertMode;
const allTuningSliderElements = $('#tuningMasterSlider, #tuningPDRatioSlider, #tuningPDGainSlider,\
#tuningResponseSlider, #tuningGyroFilterSlider, #tuningDTermFilterSlider');
if (this.expertMode) {
allTuningSliderElements.removeClass('nonExpertModeSliders');
} else {
allTuningSliderElements.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) * 10) / 10;
@ -90,8 +104,8 @@ TuningSliders.initPidSlidersPosition = function() {
}; };
TuningSliders.initGyroFilterSliderPosition = function() { TuningSliders.initGyroFilterSliderPosition = function() {
this.gyroFilterSliderValue = Math.round((FILTER_CONFIG.gyro_lowpass_dyn_min_hz + FILTER_CONFIG.gyro_lowpass2_hz) / this.gyroFilterSliderValue = Math.round((FILTER_CONFIG.gyro_lowpass_dyn_min_hz + FILTER_CONFIG.gyro_lowpass_dyn_max_hz + FILTER_CONFIG.gyro_lowpass2_hz) /
(this.FILTER_DEFAULT.gyro_lowpass_dyn_min_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); $('output[name="tuningGyroFilterSlider-number"]').val(this.gyroFilterSliderValue);
$('#tuningGyroFilterSlider').val(this.downscaleSliderValue(this.gyroFilterSliderValue)); $('#tuningGyroFilterSlider').val(this.downscaleSliderValue(this.gyroFilterSliderValue));
}; };
@ -139,10 +153,9 @@ TuningSliders.resetDTermFilterSlider = function() {
TuningSliders.updatePidSlidersDisplay = function() { TuningSliders.updatePidSlidersDisplay = function() {
// check if pid values changed manually by saving current values, doing the slider based calculation, and comaparing // check if pid values changed manually by saving current values, doing the slider based calculation, and comaparing
// if values before and after calculation, if all of them are equal the values haven't been changed manually // if values before and after calculation, if all of them are equal the values haven't been changed manually
// and the sliders are shown, otherwise sliders are grayed out and centered const WARNING_P_GAIN = 70;
const WARNING_P_GAIN = 110;
const WARNING_I_GAIN = 120; const WARNING_I_GAIN = 120;
const WARNING_DMAX_GAIN = 70; const WARNING_DMAX_GAIN = 60;
const WARNING_DMIN_GAIN = 40; const WARNING_DMIN_GAIN = 40;
this.pidSlidersUnavailable = false; this.pidSlidersUnavailable = false;
@ -172,26 +185,21 @@ TuningSliders.updatePidSlidersDisplay = function() {
this.pidSlidersUnavailable = true; this.pidSlidersUnavailable = true;
} }
if (this.pidSlidersUnavailable) { if (!this.pidSlidersUnavailable) {
$('.tuningPIDSliders').hide();
$('.slidersDisabled').show();
} else {
$('.tuningPIDSliders').show();
$('.slidersDisabled').hide();
this.cachedPidSliderValues = true; this.cachedPidSliderValues = true;
} }
if ((PIDs[1][0] > WARNING_P_GAIN || PIDs[1][1] > WARNING_I_GAIN || PIDs[1][2] > WARNING_DMAX_GAIN || ADVANCED_TUNING.dMinPitch > WARNING_DMIN_GAIN) && !this.pidSlidersUnavailable) { $('.tuningPIDSliders').toggle(!this.pidSlidersUnavailable);
$('.slidersHighWarning').show(); $('.subtab-pid .slidersDisabled').toggle(this.pidSlidersUnavailable);
} else { $('.subtab-pid .nonExpertModeSlidersNote').toggle(!this.pidSlidersUnavailable && !this.expertMode);
$('.slidersHighWarning').hide(); $('.subtab-pid .slidersWarning').toggle((PIDs[1][0] > WARNING_P_GAIN || PIDs[1][1] > WARNING_I_GAIN || PIDs[1][2] > WARNING_DMAX_GAIN ||
} ADVANCED_TUNING.dMinPitch > WARNING_DMIN_GAIN) && !this.pidSlidersUnavailable);
}; };
TuningSliders.updateFilterSlidersDisplay = function() { TuningSliders.updateFilterSlidersDisplay = function() {
// check if filters changed manually by comapring current value and those based on slider position // check if filters changed manually by comapring current value and those based on slider position
// if equal filter slider is shown, otherwise it is grayed out and centered const WARNING_FILTER_HIGH_GAIN = 1.4;
const WARNING_FILTER_GAIN = 1.4; const WARNING_FILTER_LOW_GAIN = 0.7;
this.filterGyroSliderUnavailable = false; this.filterGyroSliderUnavailable = false;
this.filterDTermSliderUnavailable = false; this.filterDTermSliderUnavailable = false;
@ -222,27 +230,22 @@ TuningSliders.updateFilterSlidersDisplay = function() {
this.cachedDTermSliderValues = true; this.cachedDTermSliderValues = true;
} }
if (this.filterGyroSliderUnavailable && this.filterDTermSliderUnavailable) { $('.tuningFilterSliders').toggle(!(this.filterGyroSliderUnavailable && this.filterDTermSliderUnavailable));
$('.tuningFilterSliders').hide(); $('.subtab-filter .slidersDisabled').toggle(this.filterGyroSliderUnavailable || this.filterDTermSliderUnavailable);
} else { $('.subtab-filter .nonExpertModeSlidersNote').toggle((!this.filterGyroSliderUnavailable || !this.filterDTermSliderUnavailable) && !this.expertMode);
$('.tuningFilterSliders').show(); $('.subtab-filter .slidersWarning').toggle(((this.gyroFilterSliderValue >= WARNING_FILTER_HIGH_GAIN ||
} this.gyroFilterSliderValue <= WARNING_FILTER_LOW_GAIN) && !this.filterGyroSliderUnavailable) ||
if (this.filterGyroSliderUnavailable || this.filterDTermSliderUnavailable) { ((this.dtermFilterSliderValue >= WARNING_FILTER_HIGH_GAIN ||
$('.slidersFilterDisabled').show(); this.dtermFilterSliderValue <= WARNING_FILTER_LOW_GAIN) && !this.filterDTermSliderUnavailable));
} else {
$('.slidersFilterDisabled').hide();
}
if ((this.gyroFilterSliderValue >= WARNING_FILTER_GAIN && !this.filterGyroSliderUnavailable) || (this.dtermFilterSliderValue >= WARNING_FILTER_GAIN && !this.filterDTermSliderUnavailable)) {
$('.slidersFilterHighWarning').show();
} else {
$('.slidersFilterHighWarning').hide();
}
}; };
TuningSliders.calculateNewPids = function() { TuningSliders.calculateNewPids = function() {
// this is the main calculation for PID sliders, inputs are in form of slider position values // 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 // values get set both into forms and their respective variables
const MAX_PID_GAIN = 200;
const MAX_DMIN_GAIN = 100;
const MAX_FF_GAIN = 2000;
if (this.dMinFeatureEnabled) { if (this.dMinFeatureEnabled) {
//dmin //dmin
ADVANCED_TUNING.dMinRoll = Math.round(this.PID_DEFAULT[3] * this.PDGainSliderValue); ADVANCED_TUNING.dMinRoll = Math.round(this.PID_DEFAULT[3] * this.PDGainSliderValue);
@ -277,16 +280,16 @@ 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++) {
PIDs[j][i] = Math.min(Math.round(PIDs[j][i] * this.MasterSliderValue), 200); PIDs[j][i] = Math.min(Math.round(PIDs[j][i] * this.MasterSliderValue), MAX_PID_GAIN);
} }
} }
ADVANCED_TUNING.feedforwardRoll = Math.round(ADVANCED_TUNING.feedforwardRoll * this.MasterSliderValue); ADVANCED_TUNING.feedforwardRoll = Math.min(Math.round(ADVANCED_TUNING.feedforwardRoll * this.MasterSliderValue), MAX_FF_GAIN);
ADVANCED_TUNING.feedforwardPitch = Math.round(ADVANCED_TUNING.feedforwardPitch * this.MasterSliderValue); ADVANCED_TUNING.feedforwardPitch = Math.min(Math.round(ADVANCED_TUNING.feedforwardPitch * this.MasterSliderValue), MAX_FF_GAIN);
ADVANCED_TUNING.feedforwardYaw = Math.round(ADVANCED_TUNING.feedforwardYaw * this.MasterSliderValue); ADVANCED_TUNING.feedforwardYaw = Math.min(Math.round(ADVANCED_TUNING.feedforwardYaw * this.MasterSliderValue), MAX_FF_GAIN);
if (this.dMinFeatureEnabled) { if (this.dMinFeatureEnabled) {
ADVANCED_TUNING.dMinRoll = Math.round(ADVANCED_TUNING.dMinRoll * this.MasterSliderValue); ADVANCED_TUNING.dMinRoll = Math.min(Math.round(ADVANCED_TUNING.dMinRoll * this.MasterSliderValue), MAX_DMIN_GAIN);
ADVANCED_TUNING.dMinPitch = Math.round(ADVANCED_TUNING.dMinPitch * this.MasterSliderValue); ADVANCED_TUNING.dMinPitch = Math.min(Math.round(ADVANCED_TUNING.dMinPitch * this.MasterSliderValue), MAX_DMIN_GAIN);
ADVANCED_TUNING.dMinYaw = Math.round(ADVANCED_TUNING.dMinYaw * this.MasterSliderValue); ADVANCED_TUNING.dMinYaw = Math.min(Math.round(ADVANCED_TUNING.dMinYaw * this.MasterSliderValue), MAX_DMIN_GAIN);
} }
$('output[name="tuningMasterSlider-number"]').val(this.MasterSliderValue); $('output[name="tuningMasterSlider-number"]').val(this.MasterSliderValue);

View file

@ -1434,6 +1434,16 @@ TABS.pid_tuning.initialize = function (callback) {
// filter and tuning sliders // filter and tuning sliders
TuningSliders.initialize(); TuningSliders.initialize();
// UNSCALED non expert slider constrain values
const NON_EXPERT_SLIDER_MAX = 1.25;
const NON_EXPERT_SLIDER_MIN = 0.7;
$('input[name="expertModeCheckbox"]').change(function() {
TuningSliders.setExpertMode($(this).is(':checked'));
TuningSliders.updatePidSlidersDisplay();
TuningSliders.updateFilterSlidersDisplay();
});
$('#dMinSwitch').change(function() { $('#dMinSwitch').change(function() {
TuningSliders.setDMinFeatureEnabled($(this).is(':checked')); TuningSliders.setDMinFeatureEnabled($(this).is(':checked'));
// switch dmin and dmax values on dmin on/off if sliders available // switch dmin and dmax values on dmin on/off if sliders available
@ -1462,6 +1472,13 @@ TABS.pid_tuning.initialize = function (callback) {
} else { } else {
slider.attr('step', 0.1); slider.attr('step', 0.1);
} }
if (!TuningSliders.expertMode) {
if (slider.val() > NON_EXPERT_SLIDER_MAX) {
slider.val(NON_EXPERT_SLIDER_MAX);
} else if (slider.val() < NON_EXPERT_SLIDER_MIN) {
slider.val(NON_EXPERT_SLIDER_MIN);
}
}
const scaledValue = TuningSliders.scaleSliderValue(slider.val()); const scaledValue = TuningSliders.scaleSliderValue(slider.val());
if (slider.is('#tuningMasterSlider')) { if (slider.is('#tuningMasterSlider')) {
TuningSliders.MasterSliderValue = scaledValue; TuningSliders.MasterSliderValue = scaledValue;
@ -1519,6 +1536,13 @@ TABS.pid_tuning.initialize = function (callback) {
// filter slider inputs // filter slider inputs
$('#tuningGyroFilterSlider, #tuningDTermFilterSlider').on('input', function() { $('#tuningGyroFilterSlider, #tuningDTermFilterSlider').on('input', function() {
const slider = $(this); const slider = $(this);
if (!TuningSliders.expertMode) {
if (slider.val() > NON_EXPERT_SLIDER_MAX) {
slider.val(NON_EXPERT_SLIDER_MAX);
} else if (slider.val() < NON_EXPERT_SLIDER_MIN) {
slider.val(NON_EXPERT_SLIDER_MIN);
}
}
const scaledValue = TuningSliders.scaleSliderValue(slider.val()); const scaledValue = TuningSliders.scaleSliderValue(slider.val());
if (slider.is('#tuningGyroFilterSlider')) { if (slider.is('#tuningGyroFilterSlider')) {
TuningSliders.gyroFilterSliderValue = scaledValue; TuningSliders.gyroFilterSliderValue = scaledValue;
@ -1571,11 +1595,10 @@ TABS.pid_tuning.initialize = function (callback) {
$('.tuningHelp').hide(); $('.tuningHelp').hide();
} else { } else {
$('.tuningPIDSliders').hide(); $('.tuningPIDSliders').hide();
$('.slidersDisabled').hide();
$('.slidersHighWarning').hide();
$('.tuningFilterSliders').hide(); $('.tuningFilterSliders').hide();
$('.slidersFilterDisabled').hide(); $('.slidersDisabled').hide();
$('.slidersFilterHighWarning').hide(); $('.slidersWarning').hide();
$('.nonExpertModeSlidersNote').hide();
$('.tuningHelpSliders').hide(); $('.tuningHelpSliders').hide();
} }

View file

@ -71,8 +71,8 @@
<div class="note dMinDisabledNote"> <div class="note dMinDisabledNote">
<p i18n="pidTuningDMinDisabledNote"></p> <p i18n="pidTuningDMinDisabledNote"></p>
</div> </div>
<div class="note slidersHighWarning"> <div class="note slidersWarning">
<p i18n="pidTuningSliderHighWarning"></p> <p i18n="pidTuningSliderWarning"></p>
</div> </div>
<div class="gui_box grey"> <div class="gui_box grey">
<table id="pid_main" class="pid_tuning"> <table id="pid_main" class="pid_tuning">
@ -166,6 +166,10 @@
</table> </table>
</div> </div>
<div class="gui_box topspacer nonExpertModeSlidersNote">
<p i18n="pidTuningSlidersNonExpertMode"></p>
</div>
<!-- TUNING SLIDERS--> <!-- TUNING SLIDERS-->
<div class="gui_box grey topspacer tuningPIDSliders"> <div class="gui_box grey topspacer tuningPIDSliders">
<table class="pid_titlebar"> <table class="pid_titlebar">
@ -825,10 +829,10 @@
<div class="note dynamicNotchWarning"> <div class="note dynamicNotchWarning">
<p i18n="pidTuningDynamicNotchFilterDisabledWarning"></p> <p i18n="pidTuningDynamicNotchFilterDisabledWarning"></p>
</div> </div>
<div class="note slidersFilterHighWarning"> <div class="note slidersWarning">
<p i18n="pidTuningSliderHighWarning"></p> <p i18n="pidTuningSliderWarning"></p>
</div> </div>
<div class="gui_box slidersFilterDisabled"> <div class="gui_box slidersDisabled">
<table class="note-button"> <table class="note-button">
<td i18n="pidTuningSlidersDisabled"></td> <td i18n="pidTuningSlidersDisabled"></td>
<td> <td>
@ -836,6 +840,9 @@
</td> </td>
</table> </table>
</div> </div>
<div class="gui_box topspacer nonExpertModeSlidersNote">
<p i18n="pidTuningSlidersNonExpertMode"></p>
</div>
<!-- Filter Slider --> <!-- Filter Slider -->
<div class="gui_box grey topspacer tuningFilterSliders"> <div class="gui_box grey topspacer tuningFilterSliders">