Rev 2592 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2592 | Rev 2627 | ||
---|---|---|---|
Line 224... | Line 224... | ||
224 | TCCR2A |= (1<<COM2A1); // set or clear at compare match depends on value of COM2A0 |
224 | TCCR2A |= (1<<COM2A1); // set or clear at compare match depends on value of COM2A0 |
Line 225... | Line 225... | ||
225 | 225 | ||
226 | // Timer/Counter 2 Interrupt Mask Register |
226 | // Timer/Counter 2 Interrupt Mask Register |
227 | // Enable timer output compare match A Interrupt only |
227 | // Enable timer output compare match A Interrupt only |
228 | TIMSK2 &= ~((1<<OCIE2B)|(1<<TOIE2)); |
228 | TIMSK2 &= ~((1<<OCIE2B)|(1<<TOIE2)); |
Line 229... | Line 229... | ||
229 | TIMSK2 |= (1<<OCIE2A); |
229 | // TIMSK2 |= (1<<OCIE2A); -> will be done in the main() |
230 | 230 | ||
Line 231... | Line 231... | ||
231 | SREG = sreg; |
231 | SREG = sreg; |
Line 261... | Line 261... | ||
261 | LIMIT_MIN_MAX(NickServoValue,min, max); |
261 | LIMIT_MIN_MAX(NickServoValue,min, max); |
262 | } |
262 | } |
263 | else NickServoValue = (int16_t)Parameter_ServoNickControl * (MULTIPLYER*16); // direct poti control |
263 | else NickServoValue = (int16_t)Parameter_ServoNickControl * (MULTIPLYER*16); // direct poti control |
264 | } |
264 | } |
Line -... | Line 265... | ||
- | 265 | ||
265 | 266 | ||
266 | void CalculateServo(void) |
267 | void CalculateServo(unsigned char init) |
267 | { |
268 | { |
268 | signed char cosinus, sinus; |
269 | signed char cosinus, sinus; |
Line 269... | Line 270... | ||
269 | signed long nick, roll; |
270 | signed long nick, roll; |
Line 288... | Line 289... | ||
288 | } |
289 | } |
289 | else |
290 | else |
290 | { // inverting movement of servo |
291 | { // inverting movement of servo |
291 | nick = ServoNickOffset / 16 - nick; |
292 | nick = ServoNickOffset / 16 - nick; |
292 | } |
293 | } |
293 | if(EE_Parameter.ServoFilterNick) ServoNickValue = ((ServoNickValue * EE_Parameter.ServoFilterNick) + nick) / (EE_Parameter.ServoFilterNick + 1); |
294 | if(EE_Parameter.ServoFilterNick && !init) ServoNickValue = ((ServoNickValue * EE_Parameter.ServoFilterNick) + nick) / (EE_Parameter.ServoFilterNick + 1); |
294 | else ServoNickValue = nick; |
295 | else ServoNickValue = nick; |
295 | // limit servo value to its parameter range definition |
296 | // limit servo value to its parameter range definition |
296 | if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER)) |
297 | if(ServoNickValue < ((int16_t)EE_Parameter.ServoNickMin * MULTIPLYER)) |
297 | { |
298 | { |
298 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
299 | ServoNickValue = (int16_t)EE_Parameter.ServoNickMin * MULTIPLYER; |
Line 317... | Line 318... | ||
317 | } |
318 | } |
318 | else |
319 | else |
319 | { // inverting movement of servo |
320 | { // inverting movement of servo |
320 | roll = ServoRollOffset / 16 - roll; |
321 | roll = ServoRollOffset / 16 - roll; |
321 | } |
322 | } |
322 | if(EE_Parameter.ServoFilterRoll) ServoRollValue = ((ServoRollValue * EE_Parameter.ServoFilterRoll) + roll) / (EE_Parameter.ServoFilterRoll + 1); |
323 | if(EE_Parameter.ServoFilterRoll && !init) ServoRollValue = ((ServoRollValue * EE_Parameter.ServoFilterRoll) + roll) / (EE_Parameter.ServoFilterRoll + 1); |
323 | else ServoRollValue = roll; |
324 | else ServoRollValue = roll; |
324 | // limit servo value to its parameter range definition |
325 | // limit servo value to its parameter range definition |
325 | if(ServoRollValue < ((int16_t)EE_Parameter.ServoRollMin * MULTIPLYER)) |
326 | if(ServoRollValue < ((int16_t)EE_Parameter.ServoRollMin * MULTIPLYER)) |
326 | { |
327 | { |
327 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMin * MULTIPLYER; |
328 | ServoRollValue = (int16_t)EE_Parameter.ServoRollMin * MULTIPLYER; |