Skip to content

Commit b8d0481

Browse files
authored
Merge pull request #2053 from mikeller/fix_sliders_resetting
Fixed PID tuning sliders disabling on certain values.
2 parents 0ee367b + 81c41d3 commit b8d0481

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/js/TuningSliders.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ var TuningSliders = {
2424
expertMode: false,
2525
};
2626

27+
const D_MIN_RATIO = 0.85;
28+
2729
TuningSliders.initialize = function() {
2830
this.PID_DEFAULT = FC.getPidDefaults();
2931
this.FILTER_DEFAULT = FC.getFilterDefaults();
@@ -49,7 +51,7 @@ TuningSliders.setDMinFeatureEnabled = function(dMinFeatureEnabled) {
4951
if (this.dMinFeatureEnabled) {
5052
this.defaultPDRatio = this.PID_DEFAULT[2] / this.PID_DEFAULT[0];
5153
} else {
52-
this.defaultPDRatio = this.PID_DEFAULT[2] / (this.PID_DEFAULT[0] * 1.18);
54+
this.defaultPDRatio = this.PID_DEFAULT[2] / (this.PID_DEFAULT[0] * (1 / D_MIN_RATIO));
5355
}
5456
};
5557

@@ -88,7 +90,7 @@ TuningSliders.initPidSlidersPosition = function() {
8890
if (this.dMinFeatureEnabled) {
8991
this.PDGainSliderValue = Math.round(ADVANCED_TUNING.dMinRoll / this.PDRatioSliderValue / this.MasterSliderValue / this.PID_DEFAULT[3] * 10) / 10;
9092
} else {
91-
this.PDGainSliderValue = Math.round(PIDs[0][0] / this.MasterSliderValue / (this.PID_DEFAULT[2] * 1.18) * 10) / 10;
93+
this.PDGainSliderValue = Math.round(PIDs[0][0] / this.MasterSliderValue / (this.PID_DEFAULT[2] * (1 / D_MIN_RATIO)) * 10) / 10;
9294
}
9395
this.ResponseSliderValue = Math.round(ADVANCED_TUNING.feedforwardRoll / this.MasterSliderValue / this.PID_DEFAULT[4] * 10) / 10;
9496

@@ -258,8 +260,8 @@ TuningSliders.calculateNewPids = function() {
258260
} else {
259261
ADVANCED_TUNING.dMinRoll = 0;
260262
ADVANCED_TUNING.dMinPitch = 0;
261-
PIDs[0][2] = Math.round((this.PID_DEFAULT[2] * 0.85) * this.PDGainSliderValue * this.PDRatioSliderValue);
262-
PIDs[1][2] = Math.round((this.PID_DEFAULT[7] * 0.85) * this.PDGainSliderValue * this.PDRatioSliderValue);
263+
PIDs[0][2] = Math.round((this.PID_DEFAULT[2] * D_MIN_RATIO) * this.PDGainSliderValue * this.PDRatioSliderValue);
264+
PIDs[1][2] = Math.round((this.PID_DEFAULT[7] * D_MIN_RATIO) * this.PDGainSliderValue * this.PDRatioSliderValue);
263265
}
264266
// p
265267
PIDs[0][0] = Math.round(this.PID_DEFAULT[0] * this.PDGainSliderValue);

0 commit comments

Comments
 (0)