Skip to content

Commit 040e090

Browse files
committed
Better rate curve // Still needs some optimising
1 parent 4f76835 commit 040e090

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tabs/pid_tuning.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,9 @@ TABS.pid_tuning.initialize = function (callback) {
361361
$('.pid_tuning .roll_pitch_rate').hide();
362362
}
363363

364-
function drawRateCurve(rateElement, expoElement, canvasElement) {
364+
function drawRateCurve(rateElement, sRateElement, expoElement, canvasElement) {
365365
var rate = parseFloat(rateElement.val()),
366+
sRate = parseFloat(sRateElement.val()),
366367
expo = parseFloat(expoElement.val()),
367368
context = canvasElement.getContext("2d");
368369

@@ -377,6 +378,7 @@ TABS.pid_tuning.initialize = function (callback) {
377378

378379
// math magic by englishman
379380
var ratey = rateHeight * rate;
381+
ratey = 1 / (1 - ((ratey / rateHeight) * sRate))
380382

381383
// draw
382384
context.clearRect(0, 0, rateWidth, rateHeight);
@@ -394,13 +396,22 @@ TABS.pid_tuning.initialize = function (callback) {
394396
$('.pid_tuning').on('input change', function () {
395397
setTimeout(function () { // let global validation trigger and adjust the values first
396398
var rateElement = $('.pid_tuning input[name="rc_rate"]'),
399+
sRateElementRoll = $('.pid_tuning input[name="roll_rate"]'),
400+
sRateElementPitch = $('.pid_tuning input[name="pitch_rate"]'),
401+
sRateElementYaw = $('.pid_tuning input[name="yaw_rate"]'),
397402
expoElement = $('.pid_tuning input[name="rc_expo"]'),
398403
yawExpoElement = $('.pid_tuning input[name="rc_yaw_expo"]'),
399404
rcCurveElement = $('.pitch_roll_curve canvas').get(0),
400405
rcYawCurveElement = $('.yaw_curve canvas').get(0);
401406

402-
drawRateCurve(rateElement, expoElement, rcCurveElement);
403-
drawRateCurve(rateElement, yawExpoElement, rcYawCurveElement);
407+
var rateElementYaw = 1;
408+
if (CONFIG.flightControllerIdentifier == "BTFL" && semver.gte(CONFIG.flightControllerVersion, "2.8.1")) {
409+
rateElementYaw = $('.pid_tuning input[name="rc_rate_yaw"]');
410+
}
411+
412+
drawRateCurve(rateElement, sRateElementRoll, expoElement, rcCurveElement);
413+
//drawRateCurve(rateElement, sRateElementPitch, expoElement, rcCurveElement); // Add Pitch Curve
414+
drawRateCurve(rateElementYaw, sRateElementYaw, yawExpoElement, rcYawCurveElement);
404415
}, 0);
405416
}).trigger('input');
406417

0 commit comments

Comments
 (0)