Rev 2099 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2099 | - | 1 | #include "externalControl.h" |
1910 | - | 2 | #include "configuration.h" |
3 | #include "controlMixer.h" |
||
4 | |||
5 | ExternalControl_t externalControl; |
||
2099 | - | 6 | uint8_t externalControlActive = 0; |
1910 | - | 7 | |
8 | void EC_setNeutral(void) { |
||
2099 | - | 9 | // if necessary. From main.c. |
10 | externalControl.config = 0; |
||
11 | externalControl.pitch = 0; |
||
12 | externalControl.roll = 0; |
||
13 | externalControl.yaw = 0; |
||
14 | externalControl.throttle = 0; |
||
1910 | - | 15 | |
2099 | - | 16 | // From main.c. What does it do?? |
17 | externalControl.digital[0] = 0x55; |
||
1910 | - | 18 | } |
19 | |||
2103 | - | 20 | void EC_periodicTaskAndPRYT(int16_t* PRYT) { |
2099 | - | 21 | if (externalControlActive) { |
22 | externalControlActive--; |
||
2103 | - | 23 | PRYT[CONTROL_ELEVATOR] += externalControl.pitch * 8; |
24 | PRYT[CONTROL_AILERONS] += externalControl.roll * 8; |
||
25 | PRYT[CONTROL_THROTTLE] += externalControl.throttle * 8; |
||
26 | PRYT[CONTROL_RUDDER] += externalControl.yaw * 8; |
||
2099 | - | 27 | } |
1910 | - | 28 | } |
29 | |||
30 | uint8_t EC_getArgument(void) { |
||
2099 | - | 31 | return externalControl.config; |
1910 | - | 32 | } |
33 | |||
34 | uint8_t EC_getCommand(void) { |
||
2099 | - | 35 | return externalControl.free; |
1910 | - | 36 | } |
37 | |||
38 | // not implemented. |
||
39 | int16_t EC_getVariable(uint8_t varNum) { |
||
2099 | - | 40 | return 0; |
1910 | - | 41 | } |
42 | |||
43 | uint8_t EC_getSignalQuality(void) { |
||
44 | if (externalControlActive > 40) |
||
45 | // Configured and heard from recently |
||
46 | return SIGNAL_GOOD; |
||
2099 | - | 47 | |
1910 | - | 48 | if (externalControlActive) |
49 | // Configured and heard from |
||
50 | return SIGNAL_OK; |
||
2099 | - | 51 | |
52 | if (!(externalControl.config & 0x01 && dynamicParams.externalControl > 128)) |
||
1910 | - | 53 | // External control is not even configured. |
54 | return NO_SIGNAL; |
||
2099 | - | 55 | |
1910 | - | 56 | // Configured but expired. |
57 | return SIGNAL_LOST; |
||
58 | } |