Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 2014 → Rev 2015

/branches/dongfang_FC_rewrite/ENC-03_FC1.3.c
9,9 → 9,6
#define PITCHROLL_MINLIMIT GYRO_SUMMATION_FACTOR_PITCHROLL * 510
#define PITCHROLL_MAXLIMIT GYRO_SUMMATION_FACTOR_PITCHROLL * 515
 
const uint8_t GYRO_REVERSED[3] = { 0, 0, 1 };
const uint8_t ACC_REVERSED[3] = { 0, 1, 0 };
 
void gyro_calibrate(void) {
printf("gyro_calibrate");
uint8_t i, axis, factor, numberOfAxesInRange = 0;
18,9 → 15,10
// GyroDefectNick = 0; GyroDefectRoll = 0; GyroDefectYaw = 0;
for (i = 140; i != 0; i--) {
delay_ms_with_adc_measurement(i <= 10 ? 10 : 2, 1);
// If all 3 axis are in range, shorten the remaining number of iterations.
if (numberOfAxesInRange == 3 && i > 10)
i = 10;
if (numberOfAxesInRange == 3 && i > 10) i = 10;
numberOfAxesInRange = 0;
 
30,9 → 28,9
else
factor = GYRO_SUMMATION_FACTOR_PITCHROLL;
 
if (rawGyroSum[axis] < 510 * factor)
if (rawGyroValue(axis) < 510 * factor)
gyroAmplifierOffset.offsets[axis]--;
else if (rawGyroSum[axis] > 515 * factor)
else if (rawGyroValue(axis) > 515 * factor)
gyroAmplifierOffset.offsets[axis]++;
else
numberOfAxesInRange++;
46,11 → 44,9
}
gyro_loadAmplifierOffsets(0);
 
delay_ms_with_adc_measurement(i <= 10 ? 10 : 2);
}
gyroAmplifierOffset_writeToEEProm();
delay_ms_with_adc_measurement(70);
delay_ms_with_adc_measurement(70, 0);
}
 
void gyro_loadAmplifierOffsets(uint8_t overwriteWithDefaults) {