Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2054 → Rev 2055

/branches/dongfang_FC_rewrite/controlMixer.c
5,6 → 5,7
#include "attitudeControl.h"
#include "externalControl.h"
#include "compassControl.h"
#include "failsafeControl.h"
#include "naviControl.h"
#include "configuration.h"
#include "attitude.h"
44,24 → 45,14
 
void controlMixer_setNeutral() {
for (uint8_t i=0; i<VARIABLE_COUNT; i++) {
variables[i] = 0;
variables[i] = RC_getVariable(i);
}
EC_setNeutral();
HC_setGround();
FC_setNeutral(); // FC is FailsafeControl, not FlightCtrl.
}
 
/*
* Set the potientiometer values to the momentary values of the respective R/C channels.
* No slew rate limitation.
*/
void controlMixer_initVariables(void) {
uint8_t i;
for (i=0; i < VARIABLE_COUNT; i++) {
variables[i] = RC_getVariable(i);
}
}
 
/*
* Update potentiometer values with limited slew rate. Could be made faster if desired.
* TODO: It assumes R/C as source. Not necessarily true.
*/
100,7 → 91,7
controlActivity += tmp;
else controlActivity = 0xffff;
*/
if (controlActivity + (uint16_t)tmp < 32768)
if (controlActivity + (uint16_t)tmp < 0x8000)
controlActivity += tmp;
}
 
166,12 → 157,16
// Add compass control (could also have been before navi, they are independent)
CC_periodicTaskAndPRTY(tempPRTY);
 
// Add height control (could also have been before navi and/or compass, they are independent)
HC_periodicTaskAndPRTY(tempPRTY);
FC_periodicTaskAndPRTY(tempPRTY);
 
// Add attitude control (could also have been before navi and/or compass, they are independent)
AC_getPRTY(tempPRTY);
if (!MKFlags & MKFLAG_EMERGENCY_FLIGHT) {
// Add height control (could also have been before navi and/or compass, they are independent)
HC_periodicTaskAndPRTY(tempPRTY);
 
// Add attitude control (could also have been before navi and/or compass, they are independent)
AC_getPRTY(tempPRTY);
}
 
// Commit results to global variable and also measure control activity.
controls[CONTROL_THROTTLE] = tempPRTY[CONTROL_THROTTLE];
updateControlAndMeasureControlActivity(CONTROL_PITCH, tempPRTY[CONTROL_PITCH]);
178,8 → 173,7
updateControlAndMeasureControlActivity(CONTROL_ROLL, tempPRTY[CONTROL_ROLL]);
updateControlAndMeasureControlActivity(CONTROL_YAW, tempPRTY[CONTROL_YAW]);
dampenControlActivity();
 
debugOut.analog[17] = controlActivity/10;
//debugOut.analog[17] = controlActivity/10;
// We can safely do this even with a bad signal - the variables will not have been updated then.
configuration_applyVariablesToParams();