139,15 → 139,17 |
value = controlServos[axis]; |
|
// Apply configurable limits. These are signed: +-128 is twice the normal +- 0.5 ms limit and +- 64 is normal. |
int16_t min = (staticParams.servos[axis].minValue * SERVO_NORMAL_LIMIT) >> 6; |
int16_t max = (staticParams.servos[axis].maxValue * SERVO_NORMAL_LIMIT) >> 6; |
int16_t min = (int16_t)staticParams.servos[axis].minValue * (SERVO_NORMAL_LIMIT >> 6); |
int16_t max = (int16_t)staticParams.servos[axis].maxValue * (SERVO_NORMAL_LIMIT >> 6); |
|
if (value < min) value = min; |
if (value < -min) value = -min; |
else if (value > max) value = max; |
|
if (value < -SERVO_ABS_LIMIT) value = -SERVO_ABS_LIMIT; |
else if (value > SERVO_ABS_LIMIT) value = SERVO_ABS_LIMIT; |
|
debugOut.analog[24+axis] = value; |
|
servoValues[axis] = value + NEUTRAL_PULSELENGTH; |
} |
} |
173,6 → 175,8 |
} |
*/ |
|
uint8_t finalServoMap[] = {1,0,0,2,4,5,6,7}; |
|
ISR(TIMER2_COMPA_vect) { |
static uint16_t remainingPulseTime; |
static uint8_t servoIndex = 0; |
182,7 → 186,7 |
// Pulse is over, and the next pulse has already just started. Calculate length of next pulse. |
if (servoIndex < staticParams.servoCount) { |
// There are more signals to output. |
sumOfPulseTimes += (remainingPulseTime = servoValues[servoIndex]); |
sumOfPulseTimes += (remainingPulseTime = servoValues[finalServoMap[servoIndex]]); |
servoIndex++; |
} else { |
// There are no more signals. Reset the counter and make this pulse cover the missing frame time. |