Rev 1910 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1910 | Rev 2099 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "externalcontrol.h" |
1 | #include "externalControl.h" |
2 | #include "configuration.h" |
2 | #include "configuration.h" |
3 | #include "controlMixer.h" |
3 | #include "controlMixer.h" |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | ExternalControl_t externalControl; |
5 | ExternalControl_t externalControl; |
6 | uint8_t externalControlActive; |
- | |
7 | 6 | uint8_t externalControlActive = 0; |
|
8 | int16_t EC_EATR[4]; |
- | |
9 | 7 | // int16_t EC_PRTY[4]; |
|
- | 8 | // TODO: Who is going to call this |
|
10 | // TODO: Who is going to call this |
9 | |
11 | void EC_setNeutral(void) { |
10 | void EC_setNeutral(void) { |
12 | // if necessary. From main.c. |
11 | // if necessary. From main.c. |
13 | externalControl.config = 0; |
12 | externalControl.config = 0; |
14 | externalControl.pitch = 0; |
13 | externalControl.pitch = 0; |
Line 18... | Line 17... | ||
18 | 17 | ||
19 | // From main.c. What does it do?? |
18 | // From main.c. What does it do?? |
20 | externalControl.digital[0] = 0x55; |
19 | externalControl.digital[0] = 0x55; |
Line -... | Line 20... | ||
- | 20 | } |
|
21 | } |
21 | |
22 | 22 | void EC_periodicTaskAndPRTY(int16_t* PRTY) { |
|
- | 23 | if (externalControlActive) { |
|
- | 24 | externalControlActive--; |
|
- | 25 | PRTY[CONTROL_ELEVATOR] += externalControl.pitch * 8; |
|
- | 26 | PRTY[CONTROL_AILERONS] += externalControl.roll * 8; |
|
- | 27 | PRTY[CONTROL_THROTTLE] += externalControl.throttle * 8; |
|
23 | int16_t* EC_getEATR(void) { |
28 | PRTY[CONTROL_RUDDER] += externalControl.yaw * 8; |
Line 24... | Line 29... | ||
24 | return EC_EATR; |
29 | } |
25 | } |
30 | } |
26 | 31 | ||
Line 35... | Line 40... | ||
35 | // not implemented. |
40 | // not implemented. |
36 | int16_t EC_getVariable(uint8_t varNum) { |
41 | int16_t EC_getVariable(uint8_t varNum) { |
37 | return 0; |
42 | return 0; |
38 | } |
43 | } |
Line 39... | Line -... | ||
39 | - | ||
40 | void EC_update() { |
- | |
41 | if (externalControlActive) { |
- | |
42 | externalControlActive--; |
- | |
43 | EC_EATR[CONTROL_ELEVATOR] = externalControl.pitch * 4; |
- | |
44 | EC_EATR[CONTROL_AILERONS] = externalControl.roll * 4; |
- | |
45 | EC_EATR[CONTROL_THROTTLE] = externalControl.throttle; |
- | |
46 | EC_EATR[CONTROL_RUDDER ] = externalControl.yaw; // No stickP or similar?????? |
- | |
47 | } else { |
- | |
48 | EC_EATR[CONTROL_ELEVATOR] = EC_EATR[CONTROL_AILERONS] = EC_EATR[CONTROL_THROTTLE] = EC_EATR[CONTROL_RUDDER] = 0; |
- | |
49 | } |
- | |
50 | } |
- | |
51 | 44 | ||
52 | uint8_t EC_getSignalQuality(void) { |
45 | uint8_t EC_getSignalQuality(void) { |
53 | if (externalControlActive > 40) |
46 | if (externalControlActive > 40) |
54 | // Configured and heard from recently |
47 | // Configured and heard from recently |
Line 55... | Line 48... | ||
55 | return SIGNAL_GOOD; |
48 | return SIGNAL_GOOD; |
56 | 49 | ||
57 | if (externalControlActive) |
50 | if (externalControlActive) |
Line 58... | Line 51... | ||
58 | // Configured and heard from |
51 | // Configured and heard from |
59 | return SIGNAL_OK; |
52 | return SIGNAL_OK; |
60 | 53 | ||
Line 61... | Line 54... | ||
61 | if (!(externalControl.config & 0x01 && dynamicParams.ExternalControl > 128)) |
54 | if (!(externalControl.config & 0x01 && dynamicParams.externalControl > 128)) |
62 | // External control is not even configured. |
55 | // External control is not even configured. |