Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2108 - 1
#include "externalControl.h"
2
#include "configuration.h"
3
#include "controlMixer.h"
4
 
5
ExternalControl_t externalControl;
6
uint8_t externalControlActive = 0;
7
 
8
void EC_setNeutral(void) {
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;
15
 
16
  // From main.c. What does it do??
17
  externalControl.digital[0] = 0x55;
18
}
19
 
20
void EC_periodicTaskAndPRYT(int16_t* PRYT) {
21
  if (externalControlActive) {
22
    externalControlActive--;
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;
27
  }
28
}
29
 
30
uint8_t EC_getArgument(void) {
31
  return externalControl.config;
32
}
33
 
34
uint8_t EC_getCommand(void) {
35
  return externalControl.free;
36
}
37
 
38
// not implemented.
39
int16_t EC_getVariable(uint8_t varNum) {
40
  return 0;
41
}
42
 
43
uint8_t EC_getSignalQuality(void) {
44
  if (externalControlActive > 40)
45
    // Configured and heard from recently
46
    return SIGNAL_GOOD;
47
 
48
  if (externalControlActive)
49
    // Configured and heard from
50
    return SIGNAL_OK;
51
 
52
  if (!(externalControl.config & 0x01 && dynamicParams.externalControl > 128))
53
    // External control is not even configured.
54
    return NO_SIGNAL;
55
 
56
  // Configured but expired.
57
  return SIGNAL_LOST;
58
}