Rev 2051 | Rev 2053 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2051 | Rev 2052 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include <stdlib.h> |
1 | #include <stdlib.h> |
2 | #include <avr/io.h> |
2 | #include <avr/io.h> |
3 | #include <avr/interrupt.h> |
3 | #include <avr/interrupt.h> |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | #include "rc.h" |
- | |
6 | #include "uart0.h" |
5 | #include "rc.h" |
7 | #include "controlMixer.h" |
6 | #include "controlMixer.h" |
8 | #include "configuration.h" |
7 | #include "configuration.h" |
- | 8 | #include "commands.h" |
|
Line 9... | Line 9... | ||
9 | #include "commands.h" |
9 | #include "output.h" |
10 | 10 | ||
11 | // The channel array is 0-based! |
11 | // The channel array is 0-based! |
12 | volatile int16_t PPM_in[MAX_CHANNELS]; |
12 | volatile int16_t PPM_in[MAX_CHANNELS]; |
Line 188... | Line 188... | ||
188 | PRTY[CONTROL_ROLL] = RCChannel(CH_ROLL) * staticParams.stickP + RCDiff(CH_ROLL) * staticParams.stickD; |
188 | PRTY[CONTROL_ROLL] = RCChannel(CH_ROLL) * staticParams.stickP + RCDiff(CH_ROLL) * staticParams.stickD; |
189 | PRTY[CONTROL_THROTTLE] = RCChannel(CH_THROTTLE) + RCDiff(CH_THROTTLE) * staticParams.stickThrottleD + 120; |
189 | PRTY[CONTROL_THROTTLE] = RCChannel(CH_THROTTLE) + RCDiff(CH_THROTTLE) * staticParams.stickThrottleD + 120; |
190 | if (PRTY[CONTROL_THROTTLE] < 0) PRTY[CONTROL_THROTTLE] = 0; // Throttle is non negative. |
190 | if (PRTY[CONTROL_THROTTLE] < 0) PRTY[CONTROL_THROTTLE] = 0; // Throttle is non negative. |
191 | tmp1 = -RCChannel(CH_YAW) - RCDiff(CH_YAW); |
191 | tmp1 = -RCChannel(CH_YAW) - RCDiff(CH_YAW); |
192 | // exponential stick sensitivity in yawing rate |
192 | // exponential stick sensitivity in yawing rate |
193 | tmp2 = (int32_t) staticParams.stickYawP * ((int32_t) tmp1 * abs(tmp1)) / 512L; // expo y = ax + bx^2 |
193 | tmp2 = (int32_t)staticParams.stickYawP * ((int32_t)tmp1 * abs(tmp1)) >> 9; // expo y = ax + bx^2 |
194 | tmp2 += (staticParams.stickYawP * tmp1) >> 2; |
194 | tmp2 += (staticParams.stickYawP * tmp1) >> 2; |
195 | PRTY[CONTROL_YAW] = tmp2; |
195 | PRTY[CONTROL_YAW] = tmp2; |
Line 196... | Line 196... | ||
196 | 196 | ||
197 | uint8_t command = RC_getStickCommand(); |
197 | uint8_t command = RC_getStickCommand(); |
Line 306... | Line 306... | ||
306 | return 5; |
306 | return 5; |
307 | return 0; |
307 | return 0; |
308 | } |
308 | } |
309 | } |
309 | } |
Line -... | Line 310... | ||
- | 310 | ||
310 | 311 | #ifdef USE_MK3MAG |
|
311 | /* |
312 | /* |
312 | * For each time the stick is pulled, returns true. |
313 | * For each time the stick is pulled, returns true. |
313 | */ |
314 | */ |
314 | uint8_t RC_testCompassCalState(void) { |
315 | uint8_t RC_testCompassCalState(void) { |
Line 321... | Line 322... | ||
321 | stickPulled = 1; |
322 | stickPulled = 1; |
322 | return 1; |
323 | return 1; |
323 | } |
324 | } |
324 | return 0; |
325 | return 0; |
325 | } |
326 | } |
- | 327 | #endif |
|
- | 328 | ||
326 | /* |
329 | /* |
327 | * Abstract controls are not used at the moment. |
330 | * Abstract controls are not used at the moment. |
328 | t_control rc_control = { |
331 | t_control rc_control = { |
329 | RC_getPitch, |
332 | RC_getPitch, |
330 | RC_getRoll, |
333 | RC_getRoll, |