Rev 2117 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2117 | Rev 2164 | ||
---|---|---|---|
Line 149... | Line 149... | ||
149 | servoValues[axis] = servoValue(axis); |
149 | servoValues[axis] = servoValue(axis); |
150 | } |
150 | } |
151 | recalculateServoTimes = 0; |
151 | recalculateServoTimes = 0; |
152 | } |
152 | } |
Line -... | Line 153... | ||
- | 153 | ||
- | 154 | uint8_t servoMap[] = {2,3,0,1,4,5,6,7}; |
|
153 | 155 | ||
154 | ISR(TIMER2_COMPA_vect) { |
156 | ISR(TIMER2_COMPA_vect) { |
155 | static uint16_t remainingPulseTime; |
157 | static uint16_t remainingPulseTime; |
156 | static uint8_t servoIndex = 0; |
158 | static uint8_t servoIndex = 0; |
Line 157... | Line 159... | ||
157 | static uint16_t sumOfPulseTimes = 0; |
159 | static uint16_t sumOfPulseTimes = 0; |
158 | 160 | ||
159 | if (!remainingPulseTime) { |
161 | if (!remainingPulseTime) { |
160 | // Pulse is over, and the next pulse has already just started. Calculate length of next pulse. |
162 | // Pulse is over, and the next pulse has already just started. Calculate length of next pulse. |
161 | if (servoIndex < staticParams.servoCount) { |
163 | if (servoIndex < staticParams.servoCount) { |
162 | // There are more signals to output. |
164 | // There are more signals to output. |
163 | sumOfPulseTimes += (remainingPulseTime = servoValues[servoIndex]); |
165 | sumOfPulseTimes += (remainingPulseTime = servoValues[servoMap[servoIndex]]); |
164 | servoIndex++; |
166 | servoIndex++; |
165 | } else { |
167 | } else { |
166 | // There are no more signals. Reset the counter and make this pulse cover the missing frame time. |
168 | // There are no more signals. Reset the counter and make this pulse cover the missing frame time. |