1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 11:59:58 +03:00

added acc_trim stuff into cli

spacing/indentation fixes
flyingwing is somewhat supported, reflect that in comment
added anti-moron gyro calibration routine... if model is getting moved while its arming... don't calculate gyro avearage because its gonna be wrong... example of fail see here: http://www.rcgroups.com/forums/showthread.php?t=1749966

git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@229 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
timecop@gmail.com 2012-10-13 12:08:56 +00:00
parent 9fc43d5357
commit 0976133f1f
5 changed files with 2594 additions and 2569 deletions

View file

@ -308,9 +308,11 @@ void Baro_update(void)
static void GYRO_Common(void)
{
int axis;
static int16_t previousGyroADC[3] = { 0, 0, 0 };
static int32_t g[3];
int axis;
static int16_t gyroMin[3];
static int16_t gyroMax[3];
if (calibratingG > 0) {
for (axis = 0; axis < 3; axis++) {
@ -319,11 +321,23 @@ static void GYRO_Common(void)
g[axis] = 0;
// Sum up 1000 readings
g[axis] += gyroADC[axis];
// g[axis] += (1000 - calibratingG) >> 1;
if (gyroMin[axis] > gyroADC[axis])
gyroMin[axis] = gyroADC[axis];
if (gyroMax[axis] < gyroADC[axis])
gyroMax[axis] = gyroADC[axis];
// Clear global variables for next reading
gyroADC[axis] = 0;
gyroZero[axis] = 0;
if (calibratingG == 1) {
int16_t gyroDiff = gyroMax[axis] - gyroMin[axis];
// check variance and startover if idiot was moving the model
if (gyroDiff > 10) {
calibratingG = 1000;
gyroMin[0] = gyroMin[1] = gyroMin[2] = 0;
gyroMax[0] = gyroMax[1] = gyroMax[2] = 0;
g[0] = g[1] = g[2] = 0;
continue;
}
gyroZero[axis] = g[axis] / 1000;
blinkLED(10, 15, 1);
}