Rev 1872 | Rev 2027 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1612 | dongfang | 1 | #include "externalcontrol.h" |
2 | #include "configuration.h" |
||
3 | #include "controlMixer.h" |
||
4 | |||
5 | ExternalControl_t externalControl; |
||
6 | uint8_t externalControlActive; |
||
7 | |||
8 | int16_t EC_PRTY[4]; |
||
9 | |||
10 | // TODO: Who is going to call this |
||
11 | void EC_setNeutral(void) { |
||
1821 | - | 12 | // if necessary. From main.c. |
13 | externalControl.config = 0; |
||
14 | externalControl.pitch = 0; |
||
15 | externalControl.roll = 0; |
||
16 | externalControl.yaw = 0; |
||
17 | externalControl.throttle = 0; |
||
18 | |||
19 | // From main.c. What does it do?? |
||
20 | externalControl.digital[0] = 0x55; |
||
1612 | dongfang | 21 | } |
22 | |||
23 | int16_t* EC_getPRTY(void) { |
||
1821 | - | 24 | return EC_PRTY; |
1612 | dongfang | 25 | } |
26 | |||
27 | uint8_t EC_getArgument(void) { |
||
1821 | - | 28 | return externalControl.config; |
1612 | dongfang | 29 | } |
30 | |||
31 | uint8_t EC_getCommand(void) { |
||
1821 | - | 32 | return externalControl.free; |
1612 | dongfang | 33 | } |
34 | |||
35 | // not implemented. |
||
36 | int16_t EC_getVariable(uint8_t varNum) { |
||
1821 | - | 37 | return 0; |
1612 | dongfang | 38 | } |
39 | |||
40 | void EC_update() { |
||
1821 | - | 41 | if (externalControlActive) { |
42 | externalControlActive--; |
||
1960 | - | 43 | EC_PRTY[CONTROL_PITCH] = externalControl.pitch * (int16_t) staticParams.stickP; |
44 | EC_PRTY[CONTROL_ROLL] = externalControl.roll * (int16_t) staticParams.stickP; |
||
1821 | - | 45 | EC_PRTY[CONTROL_THROTTLE] = externalControl.throttle; |
46 | EC_PRTY[CONTROL_YAW] = externalControl.yaw; // No stickP or similar?????? |
||
47 | } else { |
||
1872 | - | 48 | EC_PRTY[CONTROL_PITCH] = EC_PRTY[CONTROL_ROLL] = EC_PRTY[CONTROL_THROTTLE] = EC_PRTY[CONTROL_YAW] = 0; |
1821 | - | 49 | } |
1612 | dongfang | 50 | } |
51 | |||
52 | uint8_t EC_getSignalQuality(void) { |
||
1821 | - | 53 | if (externalControlActive > 80) |
54 | // Configured and heard from recently |
||
55 | return SIGNAL_GOOD; |
||
1612 | dongfang | 56 | |
1821 | - | 57 | if (externalControlActive) |
58 | // Configured and heard from |
||
59 | return SIGNAL_OK; |
||
1612 | dongfang | 60 | |
1960 | - | 61 | if (!(externalControl.config & 0x01 && dynamicParams.externalControl > 128)) |
1821 | - | 62 | // External control is not even configured. |
63 | return NO_SIGNAL; |
||
1617 | dongfang | 64 | |
1821 | - | 65 | // Configured but expired. |
66 | return SIGNAL_LOST; |
||
1612 | dongfang | 67 | } |