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

Merge pull request #11126 from mathiasvr/pr-int-exp

Use macros for power with integer exponents
This commit is contained in:
J Blackman 2022-06-28 15:28:35 +10:00 committed by GitHub
commit 00cd0e52e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 5 deletions

View file

@ -338,7 +338,7 @@ float pidCompensateThrustLinearization(float throttle)
if (pidRuntime.thrustLinearization != 0.0f) {
// for whoops where a lot of TL is needed, allow more throttle boost
const float throttleReversed = (1.0f - throttle);
throttle /= 1.0f + pidRuntime.throttleCompensateAmount * powf(throttleReversed, 2);
throttle /= 1.0f + pidRuntime.throttleCompensateAmount * sq(throttleReversed);
}
return throttle;
}
@ -348,7 +348,7 @@ float pidApplyThrustLinearization(float motorOutput)
if (pidRuntime.thrustLinearization != 0.0f) {
if (motorOutput > 0.0f) {
const float motorOutputReversed = (1.0f - motorOutput);
motorOutput *= 1.0f + powf(motorOutputReversed, 2) * pidRuntime.thrustLinearization;
motorOutput *= 1.0f + sq(motorOutputReversed) * pidRuntime.thrustLinearization;
}
}
return motorOutput;