mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 21:05:30 +03:00
Added new rc rate calculation to rates curve. Removed SUPER_EXPO feature for >= 3.0.
Added support for RC Expo Power setting. fixed titlebar in pid tuning tab request from @mikeller #252 fixed titlebar from pid tuning and accel
This commit is contained in:
parent
158a415bfc
commit
1da5219bf2
8 changed files with 165 additions and 159 deletions
|
@ -9,18 +9,24 @@ var RateCurve = function (useLegacyCurve) {
|
|||
|
||||
this.constrain = function (value, min, max) {
|
||||
return Math.max(min, Math.min(value, max));
|
||||
}
|
||||
};
|
||||
|
||||
this.rcCommand = function (rcData, rcRate, rcExpo) {
|
||||
var tmp = Math.min(Math.abs(rcData - midRc), 500) / 100;
|
||||
this.rcCommand = function (rcData, rcRate) {
|
||||
var tmp = Math.min(Math.abs(rcData - midRc), 500);
|
||||
rcRate = rcRate;
|
||||
|
||||
var result = ((2500 + rcExpo * (tmp * tmp - 25)) * tmp * rcRate / 2500).toFixed(0);
|
||||
if (rcData < midRc) {
|
||||
if (rcRate > 2) {
|
||||
rcRate = rcRate + (rcRate - 2) * 14.54;
|
||||
}
|
||||
|
||||
var result = tmp * rcRate;
|
||||
|
||||
if (rcData < midRc) {
|
||||
result = -result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
this.drawRateCurve = function (rate, rcRate, rcExpo, superExpoActive, maxAngularVel, context, width, height) {
|
||||
var canvasHeightScale = height / (2 * maxAngularVel);
|
||||
|
@ -42,7 +48,7 @@ var RateCurve = function (useLegacyCurve) {
|
|||
context.stroke();
|
||||
|
||||
context.restore();
|
||||
}
|
||||
};
|
||||
|
||||
this.drawLegacyRateCurve = function (rate, rcRate, rcExpo, context, width, height) {
|
||||
// math magic by englishman
|
||||
|
@ -55,28 +61,31 @@ var RateCurve = function (useLegacyCurve) {
|
|||
context.quadraticCurveTo(width * 11 / 20, height - ((rateY / 2) * (1 - rcExpo)), width, height - rateY);
|
||||
context.stroke();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
RateCurve.prototype.rcCommandRawToDegreesPerSecond = function (rcData, rate, rcRate, rcExpo, superExpoActive) {
|
||||
var angleRate;
|
||||
if (rate !== undefined && rcRate !== undefined && rcExpo !== undefined) {
|
||||
rate = rate * 100;
|
||||
rcRate = rcRate * 100;
|
||||
rcExpo = rcExpo * 100;
|
||||
|
||||
var inputValue = this.rcCommand(rcData, rcRate, rcExpo);
|
||||
var inputValue = this.rcCommand(rcData, rcRate);
|
||||
var maxRc = 500 * rcRate;
|
||||
|
||||
if (superExpoActive) {
|
||||
var rcFactor = Math.abs(inputValue) / (500 * rcRate / 100);
|
||||
rcFactor = 1 / this.constrain(1 - rcFactor * rate / 100, 0.01, 1);
|
||||
|
||||
angleRate = rcFactor * 27 * inputValue / 16;
|
||||
} else {
|
||||
angleRate = (rate + 27) * inputValue / 16;
|
||||
if (rcExpo > 0) {
|
||||
var absRc = Math.abs(inputValue) / maxRc;
|
||||
inputValue = inputValue * ((rcExpo * absRc * absRc * absRc) + absRc * (1-rcExpo)); // absRc should be wrapped in function using expo power
|
||||
}
|
||||
|
||||
angleRate = this.constrain(angleRate, -8190, 8190); // Rate limit protection
|
||||
angleRate = angleRate >> 2; // the shift by 2 is to counterbalance the divide by 4 that occurs on the gyro to calculate the error
|
||||
var rcInput = inputValue / maxRc;
|
||||
|
||||
if (superExpoActive) {
|
||||
var rcFactor = 1 / this.constrain(1 - Math.abs(rcInput) * rate, 0.01, 1);
|
||||
angleRate = 200 * rcRate * rcInput; // 200 should be variable checked on version (older versions it's 205,9)
|
||||
angleRate = angleRate * rcFactor;
|
||||
} else {
|
||||
angleRate = (((rate * 100) + 27) * inputValue / 16) / 4.1; // Only applies to old versions ?
|
||||
}
|
||||
|
||||
angleRate = this.constrain(angleRate, -1998, 1998); // Rate limit protection
|
||||
}
|
||||
|
||||
return angleRate;
|
||||
|
@ -89,7 +98,7 @@ RateCurve.prototype.getMaxAngularVel = function (rate, rcRate, rcExpo, superExpo
|
|||
}
|
||||
|
||||
return maxAngularVel;
|
||||
}
|
||||
};
|
||||
|
||||
RateCurve.prototype.draw = function (rate, rcRate, rcExpo, superExpoActive, maxAngularVel, context) {
|
||||
if (rate !== undefined && rcRate !== undefined && rcExpo !== undefined) {
|
||||
|
@ -102,4 +111,4 @@ RateCurve.prototype.draw = function (rate, rcRate, rcExpo, superExpoActive, maxA
|
|||
this.drawRateCurve(rate, rcRate, rcExpo, superExpoActive, maxAngularVel, context, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue