Skip to content

Commit

Permalink
Style changes, use 16 bit int for calculated servo value
Browse files Browse the repository at this point in the history
  • Loading branch information
lazd committed Jul 15, 2015
1 parent 26decb6 commit b026b39
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,11 @@ void writeAllMotors(int16_t mc)
writeMotors();
}

static void resetServos(void) {
// reset all servos to their middle value
static void resetServos(void)
{
uint8_t i;

// reset all servos to their middle value
for (i = 0; i < MAX_SERVOS; i++)
servo[i] = servoMiddle(i);
}
Expand Down Expand Up @@ -529,8 +531,7 @@ static void servoMixer(void)
if (currentServoMixer[i].speed == 0) {
// directly use the input value if speed is not provided
currentOutput[i] = input[from];
}
else {
} else {
// apply speed constraints
if (currentOutput[i] < input[from])
currentOutput[i] = constrain(currentOutput[i] + currentServoMixer[i].speed, currentOutput[i], input[from]);
Expand All @@ -539,7 +540,7 @@ static void servoMixer(void)
}

// start with the output value
servo[target] = (int32_t)currentOutput[i];
servo[target] = (int16_t)currentOutput[i];

// apply rate from mixer rule
servo[target] *= ((float)currentServoMixer[i].rate / 100);
Expand Down Expand Up @@ -581,8 +582,8 @@ void mixTable(void)
motor[0] = constrain(rcCommand[THROTTLE], mcfg.minthrottle, mcfg.maxthrottle);
}

// reset all servos
if (core.useServo == 1) {
// reset all servos
resetServos();
}

Expand All @@ -606,8 +607,8 @@ void mixTable(void)
}
}

// run the servo mixer if necessary
if (core.useServo == 1) {
// run the servo mixer if necessary
servoMixer();
}

Expand Down

0 comments on commit b026b39

Please sign in to comment.