Skip to content

Commit

Permalink
Calculate maxThrottleDifference before use.
Browse files Browse the repository at this point in the history
* Easier to understand.
* Reduces code size by 32 bytes.
  • Loading branch information
hydra committed Jun 10, 2015
1 parent 4e6a268 commit 78b52c5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/flight/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,11 +731,14 @@ void mixTable(void)
}
}

int16_t maxThrottleDifference = 0;
if (maxMotor > escAndServoConfig->maxthrottle) {
maxThrottleDifference = maxMotor - escAndServoConfig->maxthrottle;
}

for (i = 0; i < motorCount; i++) {
if (maxMotor > escAndServoConfig->maxthrottle) {
// this is a way to still have good gyro corrections if at least one motor reaches its max.
motor[i] -= maxMotor - escAndServoConfig->maxthrottle;
}
// this is a way to still have good gyro corrections if at least one motor reaches its max.
motor[i] -= maxThrottleDifference;

if (feature(FEATURE_3D)) {
if ((rcData[THROTTLE]) > rxConfig->midrc) {
Expand Down

1 comment on commit 78b52c5

@leothehuman
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was moved with the code calculating the max throttle value from the piece of code that is actually described in this comment. I would suggest to move everything that is described by this comment into the separate function and put the comment in it.

Please sign in to comment.