Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2088 → Rev 2159

/branches/dongfang_FC_rewrite/controlMixer.c
13,7 → 13,7
#include "output.h"
 
// uint16_t maxControl[2] = { 0, 0 };
uint16_t controlActivity = 0;
// uint16_t controlActivity = 0;
int16_t controls[4] = { 0, 0, 0, 0 };
 
// Internal variables for reading commands made with an R/C stick.
81,6 → 81,7
return rcQ > ecQ ? rcQ : ecQ;
}
 
/*
void updateControlAndMeasureControlActivity(uint8_t index, int16_t newValue) {
int16_t tmp = controls[index];
controls[index] = newValue;
89,11 → 90,12
tmp /= 2;
tmp = tmp * tmp;
// tmp += (newValue >= 0) ? newValue : -newValue;
/*
 
/ *
if (controlActivity + (uint16_t)tmp >= controlActivity)
controlActivity += tmp;
else controlActivity = 0xffff;
*/
* /
if (controlActivity + (uint16_t)tmp < 0x8000)
controlActivity += tmp;
}
105,6 → 107,7
tmp >>= CADAMPING;
controlActivity = tmp;
}
*/
 
/*
* Update the variables indicating stick position from the sum of R/C, GPS and external control
174,33 → 177,11
 
// Commit results to global variable and also measure control activity.
controls[CONTROL_THROTTLE] = tempPRTY[CONTROL_THROTTLE];
updateControlAndMeasureControlActivity(CONTROL_PITCH, tempPRTY[CONTROL_PITCH]);
updateControlAndMeasureControlActivity(CONTROL_ROLL, tempPRTY[CONTROL_ROLL]);
updateControlAndMeasureControlActivity(CONTROL_YAW, tempPRTY[CONTROL_YAW]);
dampenControlActivity();
controls[CONTROL_PITCH] = tempPRTY[CONTROL_PITCH];
controls[CONTROL_ROLL] = tempPRTY[CONTROL_ROLL];
controls[CONTROL_YAW] = tempPRTY[CONTROL_YAW];
// dampenControlActivity();
// We can safely do this even with a bad signal - the variables will not have been updated then.
configuration_applyVariablesToParams();
// part1a end.
/* This is not really necessary with the dead-band feature on all sticks (see rc.c)
if(staticParams.GlobalConfig & (CFG_COMPASS_ACTIVE | CFG_GPS_ACTIVE)) {
if (controlYaw > 2) controlYaw-= 2;
else if (controlYaw< -2) controlYaw += 2;
else controlYaw = 0;
}
*/
/*
* Record maxima. Predecessor of the control activity stuff.
for (axis = PITCH; axis <= ROLL; axis++) {
if (abs(control[axis] / CONTROL_SCALING) > maxControl[axis]) {
maxControl[axis] = abs(control[axis]) / CONTROL_SCALING;
if (maxControl[axis] > 100)
maxControl[axis] = 100;
} else if (maxControl[axis])
maxControl[axis]--;
}
*/
}