Subversion Repositories FlightCtrl

Rev

Rev 2053 | Rev 2058 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2053 Rev 2055
Line 3... Line 3...
3
#include "rc.h"
3
#include "rc.h"
4
#include "heightControl.h"
4
#include "heightControl.h"
5
#include "attitudeControl.h"
5
#include "attitudeControl.h"
6
#include "externalControl.h"
6
#include "externalControl.h"
7
#include "compassControl.h"
7
#include "compassControl.h"
-
 
8
#include "failsafeControl.h"
8
#include "naviControl.h"
9
#include "naviControl.h"
9
#include "configuration.h"
10
#include "configuration.h"
10
#include "attitude.h"
11
#include "attitude.h"
11
#include "commands.h"
12
#include "commands.h"
12
#include "output.h"
13
#include "output.h"
Line 42... Line 43...
42
  return isCommandRepeated;
43
  return isCommandRepeated;
43
}
44
}
Line 44... Line 45...
44
 
45
 
45
void controlMixer_setNeutral() {
46
void controlMixer_setNeutral() {
46
  for (uint8_t i=0; i<VARIABLE_COUNT; i++) {
47
  for (uint8_t i=0; i<VARIABLE_COUNT; i++) {
47
    variables[i] = 0;
48
    variables[i] = RC_getVariable(i);
48
  }
49
  }
49
  EC_setNeutral();
50
  EC_setNeutral();
50
  HC_setGround();
-
 
51
}
-
 
52
 
-
 
53
/*
51
  HC_setGround();
54
 * Set the potientiometer values to the momentary values of the respective R/C channels.
-
 
55
 * No slew rate limitation.
-
 
56
 */
-
 
57
void controlMixer_initVariables(void) {
-
 
58
  uint8_t i;
-
 
59
  for (i=0; i < VARIABLE_COUNT; i++) {
-
 
60
    variables[i] = RC_getVariable(i);
-
 
61
  }
52
  FC_setNeutral();  // FC is FailsafeControl, not FlightCtrl.
Line 62... Line 53...
62
}
53
}
63
 
54
 
64
/*
55
/*
Line 98... Line 89...
98
  /*
89
  /*
99
  if (controlActivity + (uint16_t)tmp >= controlActivity)
90
  if (controlActivity + (uint16_t)tmp >= controlActivity)
100
    controlActivity += tmp;
91
    controlActivity += tmp;
101
  else controlActivity = 0xffff;
92
  else controlActivity = 0xffff;
102
  */
93
  */
103
  if (controlActivity + (uint16_t)tmp < 32768)
94
  if (controlActivity + (uint16_t)tmp < 0x8000)
104
    controlActivity += tmp;
95
    controlActivity += tmp;
105
}
96
}
Line 106... Line 97...
106
 
97
 
107
#define CADAMPING 10
98
#define CADAMPING 10
Line 164... Line 155...
164
#endif
155
#endif
Line 165... Line 156...
165
 
156
 
166
  // Add compass control (could also have been before navi, they are independent)
157
  // Add compass control (could also have been before navi, they are independent)
Line 167... Line -...
167
  CC_periodicTaskAndPRTY(tempPRTY);
-
 
168
 
158
  CC_periodicTaskAndPRTY(tempPRTY);
Line -... Line 159...
-
 
159
 
-
 
160
  FC_periodicTaskAndPRTY(tempPRTY);
-
 
161
 
-
 
162
  if (!MKFlags & MKFLAG_EMERGENCY_FLIGHT) {
169
  // Add height control (could also have been before navi and/or compass, they are independent)
163
    // Add height control (could also have been before navi and/or compass, they are independent)
170
  HC_periodicTaskAndPRTY(tempPRTY);
164
    HC_periodicTaskAndPRTY(tempPRTY);
-
 
165
 
Line 171... Line 166...
171
 
166
    // Add attitude control (could also have been before navi and/or compass, they are independent)
172
  // Add attitude control (could also have been before navi and/or compass, they are independent)
167
    AC_getPRTY(tempPRTY);
173
  AC_getPRTY(tempPRTY);
168
  }
174
 
169
 
175
  // Commit results to global variable and also measure control activity.
170
  // Commit results to global variable and also measure control activity.
176
  controls[CONTROL_THROTTLE] = tempPRTY[CONTROL_THROTTLE];
171
  controls[CONTROL_THROTTLE] = tempPRTY[CONTROL_THROTTLE];
177
  updateControlAndMeasureControlActivity(CONTROL_PITCH, tempPRTY[CONTROL_PITCH]);
-
 
178
  updateControlAndMeasureControlActivity(CONTROL_ROLL, tempPRTY[CONTROL_ROLL]);
172
  updateControlAndMeasureControlActivity(CONTROL_PITCH, tempPRTY[CONTROL_PITCH]);
Line 179... Line 173...
179
  updateControlAndMeasureControlActivity(CONTROL_YAW, tempPRTY[CONTROL_YAW]);
173
  updateControlAndMeasureControlActivity(CONTROL_ROLL, tempPRTY[CONTROL_ROLL]);
180
  dampenControlActivity();
174
  updateControlAndMeasureControlActivity(CONTROL_YAW, tempPRTY[CONTROL_YAW]);
Line 181... Line 175...
181
 
175
  dampenControlActivity();