1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

Optimze pidSum calculation by storing the value rather than recalculating in multiple places.

Saves 72 bytes. Will save at least that additionally when incorporated into Runaway Takeoff Prevention (which also calculates the pidSum in two places).

Additionally adds a slight performance improvement by not repeating the floating point additions to calculate the pidSum in multiple places.  Effectively replaces 2 calculations with 1 (4 with 1 with Runaway Takeoff Prevention).
This commit is contained in:
Bruce Luckcuck 2018-01-30 09:58:41 -05:00
parent 6efe34d4da
commit fba0b2cea3
4 changed files with 12 additions and 7 deletions

View file

@ -121,6 +121,7 @@ union rollAndPitchTrims_u;
void pidController(const pidProfile_t *pidProfile, const union rollAndPitchTrims_u *angleTrim, timeUs_t currentTimeUs);
extern float axisPID_P[3], axisPID_I[3], axisPID_D[3];
extern float axisPIDSum[3];
bool airmodeWasActivated;
extern uint32_t targetPidLooptime;