Subversion Repositories FlightCtrl

Rev

Rev 2069 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2069 Rev 2189
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"
-
 
4
#include "definitions.h"
Line 4... Line 5...
4
 
5
 
5
ExternalControl_t externalControl;
6
ExternalControl_t externalControl;
6
uint8_t externalControlActive = 0;
-
 
7
// int16_t EC_PRTY[4];
7
volatile uint8_t externalControlActive;
Line 8... Line 8...
8
// TODO: Who is going to call this
8
// TODO: Who is going to call this
9
 
9
 
10
void EC_setNeutral(void) {
10
void EC_setNeutral(void) {
-
 
11
  // if necessary. From main.c.
11
  // if necessary. From main.c.
12
  externalControl.command = 0;
12
  externalControl.config = 0;
13
  externalControl.argument = 0;
13
  externalControl.pitch = 0;
14
  externalControl.pitch = 0;
14
  externalControl.roll = 0;
15
  externalControl.roll = 0;
Line 15... Line 16...
15
  externalControl.yaw = 0;
16
  externalControl.yaw = 0;
16
  externalControl.throttle = 0;
17
  externalControl.throttle = 0;
17
 
18
 
Line 18... Line 19...
18
  // From main.c. What does it do??
19
  // From main.c. What does it do??
19
  externalControl.digital[0] = 0x55;
20
  externalControl.digital[0] = 0x55;
20
}
21
}
21
 
22
 
22
void EC_periodicTaskAndPRTY(int16_t* PRTY) {
23
void EC_periodicTaskAndRPTY(int16_t* RPTY) {
23
  if (externalControlActive) {
24
  if (externalControlActive) {
24
    externalControlActive--;
25
    externalControlActive--;
25
    PRTY[CONTROL_PITCH] += externalControl.pitch * (int16_t) staticParams.stickP;
26
    RPTY[CONTROL_PITCH] += externalControl.pitch * (int16_t) staticParams.stickP;
26
    PRTY[CONTROL_ROLL] += externalControl.roll * (int16_t) staticParams.stickP;
27
    RPTY[CONTROL_ROLL] += externalControl.roll * (int16_t) staticParams.stickP;
Line 27... Line 28...
27
    PRTY[CONTROL_THROTTLE] += externalControl.throttle;
28
    RPTY[CONTROL_THROTTLE] += externalControl.throttle;
28
    PRTY[CONTROL_YAW] += externalControl.yaw; // No stickP or similar??????
29
    RPTY[CONTROL_YAW] += externalControl.yaw; // No stickP or similar??????
29
  }
30
  }
Line 30... Line 31...
30
}
31
}
31
 
32
 
32
uint8_t EC_getArgument(void) {
33
uint8_t EC_getArgument(void) {
Line 33... Line 34...
33
  return externalControl.config;
34
  return externalControl.argument;
34
}
35
}
35
 
36
 
Line 49... Line 50...
49
 
50
 
50
  if (externalControlActive)
51
  if (externalControlActive)
51
    // Configured and heard from
52
    // Configured and heard from
Line 52... Line 53...
52
    return SIGNAL_OK;
53
    return SIGNAL_OK;
53
 
54
 
54
  if (!(externalControl.config & 0x01 && dynamicParams.externalControl > 128))
55
  if (dynamicParams.externalControl < 128)
Line 55... Line 56...
55
    // External control is not even configured.
56
    // External control is not even configured.
56
    return NO_SIGNAL;
57
    return NO_SIGNAL;