Skip to content

Commit

Permalink
Update pid_tuning.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRosser committed Apr 6, 2024
1 parent 08bef5d commit 4ef5e9b
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/js/tabs/pid_tuning.js
Original file line number Diff line number Diff line change
Expand Up @@ -1722,10 +1722,10 @@ pid_tuning.initialize = function (callback) {
// y = (1-t)^2 * p0 + 2 * (1-t)*t*p1 + t^2 * p2
// y = (p2+p0-2p1)x^2 + 2(p1 - p0)x + p0
// 0 = (p2+p0-2p1)x^2 + 2(p1 - p0)x + (p0 - y)
const a = startY+endY-2*cpY
const b = 2*(cpY - startY)
const c = startY - y
return a==0? -c/b : (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a)
const a = startY+endY-2*cpY;
const b = 2*(cpY - startY);
const c = startY - y;
return a==0? -c/b : (-b + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a);
}

/* --- */
Expand Down Expand Up @@ -1781,25 +1781,23 @@ pid_tuning.initialize = function (callback) {
context.beginPath();
context.moveTo(0, canvasHeight);
if (throttleLimitType === THROTTLE_LIMIT_TYPES.CLIP){

Check failure on line 1784 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

Trailing spaces not allowed
const clippos = throttleLimitPercent <= midy
? getPosfromYBezier(throttleLimitPercent,canvasHeight,midyl, midy)
: getPosfromYBezier(throttleLimitPercent,midy, midyl, 0);
if (throttleLimitPercent <= midyl){
//first half
lowerctrl = getQuadraticCurvePoint(0, canvasHeight, midxl, midyl, midx, midy, clippos/2);
curveclip = getQuadraticCurvePoint(0, canvasHeight, midxl, midyl, midx, midy, clippos);
context.quadraticCurveTo(lowerctrl.x, lowerctrl.y, curveclip.x, curveclip.y);
context.moveTo(curveclip.x, curveclip.y);
context.lineTo(canvasWidth, curveclip.y);
let lowerctrl = getQuadraticCurvePoint(0, canvasHeight, midxl, midyl, midx, midy, clippos/2);
let curveclip = getQuadraticCurvePoint(0, canvasHeight, midxl, midyl, midx, midy, clippos);
} else {
context.quadraticCurveTo(midxl, midyl, midx, midy);
context.moveTo(midx, midy);
lowerctrl = getQuadraticCurvePoint(midx, midy, midxr, midyr, canvasWidth, 0, clippos/2);
curveclip = getQuadraticCurvePoint(midx, midy, midxr, midyr, canvasWidth, 0, clippos);
context.quadraticCurveTo(lowerctrl.x, lowerctrl.y, curveclip.x, curveclip.y);
context.moveTo(curveclip.x, curveclip.y);
context.lineTo(canvasWidth, curveclip.y);
let lowerctrl = getQuadraticCurvePoint(midx, midy, midxr, midyr, canvasWidth, 0, clippos/2);
let curveclip = getQuadraticCurvePoint(midx, midy, midxr, midyr, canvasWidth, 0, clippos);
}
context.quadraticCurveTo(lowerctrl.x, lowerctrl.y, curveclip.x, curveclip.y);

Check failure on line 1798 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

'lowerctrl' is not defined

Check failure on line 1798 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

'lowerctrl' is not defined

Check failure on line 1798 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

'curveclip' is not defined

Check failure on line 1798 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

'curveclip' is not defined
context.moveTo(curveclip.x, curveclip.y);

Check failure on line 1799 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

'curveclip' is not defined

Check failure on line 1799 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

'curveclip' is not defined
context.lineTo(canvasWidth, curveclip.y);

Check failure on line 1800 in src/js/tabs/pid_tuning.js

View workflow job for this annotation

GitHub Actions / CI / Test

'curveclip' is not defined
}
context.quadraticCurveTo(midxl, midyl, midx, midy);
context.moveTo(midx, midy);
Expand Down

0 comments on commit 4ef5e9b

Please sign in to comment.