7,6 → 7,7 |
#include "attitude.h" |
#include "printf_P.h" |
#include "isqrt.h" |
#include "sensors.h" |
|
// for Delay functions |
#include "timer0.h" |
404,14 → 405,14 |
} |
|
void analog_calibrate(void) { |
#define OFFSET_CYCLES 64 |
#define OFFSET_CYCLES 250 |
uint8_t i, axis; |
int32_t offsets[4] = { 0, 0, 0, 0}; |
int32_t offsets[4] = { 0, 0, 0, 0 }; |
gyro_calibrate(); |
|
// determine gyro bias by averaging (requires that the copter does not rotate around any axis!) |
for (i = 0; i < OFFSET_CYCLES; i++) { |
delay_ms_with_adc_measurement(10, 1); |
delay_ms_with_adc_measurement(2, 1); |
for (axis = PITCH; axis <= YAW; axis++) { |
offsets[axis] += rawGyroValue(axis); |
} |
419,7 → 420,7 |
} |
|
for (axis = PITCH; axis <= YAW; axis++) { |
gyroOffset.offsets[axis] = (offsets[axis] + OFFSET_CYCLES / 2) / OFFSET_CYCLES; |
gyroOffset.offsets[axis] = (offsets[axis] /*+ OFFSET_CYCLES/2 */) / OFFSET_CYCLES; |
int16_t min = (512-200) * GYRO_OVERSAMPLING; |
int16_t max = (512+200) * GYRO_OVERSAMPLING; |
if(gyroOffset.offsets[axis] < min || gyroOffset.offsets[axis] > max) |
426,7 → 427,7 |
versionInfo.hardwareErrors[0] |= FC_ERROR0_GYRO_PITCH << axis; |
} |
|
airpressureOffset = (offsets[3] + OFFSET_CYCLES / 2) / OFFSET_CYCLES; |
airpressureOffset = (offsets[3] /* + OFFSET_CYCLES/2 */) / OFFSET_CYCLES; |
int16_t min = 200; |
int16_t max = 1024-200; |
if(airpressureOffset < min || airpressureOffset > max) |