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