97,6 → 97,8 |
int16_t gyroD[2]; |
int16_t yawGyro; |
|
int32_t groundPressure; |
|
/* |
* Offset values. These are the raw gyro and acc. meter sums when the copter is |
* standing still. They are used for adjusting the gyro and acc. meter values |
172,6 → 174,7 |
|
// Value of AIRPRESSURE_OVERSAMPLING samples, with range, filtered. |
int32_t filteredAirPressure; |
int32_t lastFilteredAirPressure; |
|
#define MAX_AIRPRESSURE_WINDOW_LENGTH 64 |
int16_t airPressureWindow[MAX_AIRPRESSURE_WINDOW_LENGTH]; |
506,6 → 509,7 |
// 2 samples were added. |
pressureMeasurementCount += 2; |
if (pressureMeasurementCount >= AIRPRESSURE_OVERSAMPLING) { |
lastFilteredAirPressure = filteredAirPressure; |
filteredAirPressure = (filteredAirPressure * (AIRPRESSURE_FILTER - 1) |
+ airPressureSum + AIRPRESSURE_FILTER / 2) / AIRPRESSURE_FILTER; |
pressureMeasurementCount = airPressureSum = 0; |
524,7 → 528,6 |
// Battery. The measured value is: (V * 1k/11k)/3v * 1024 = 31.03 counts per volt (max. measurable is 33v). |
// This is divided by 3 --> 10.34 counts per volt. |
UBat = (3 * UBat + sensorInputs[AD_UBAT] / 3) / 4; |
debugOut.analog[11] = UBat; |
} |
|
void analog_update(void) { |
633,3 → 636,16 |
accOffset_writeToEEProm(); |
startAnalogConversionCycle(); |
} |
|
void analog_setGround() { |
groundPressure = filteredAirPressure; |
} |
|
int32_t analog_getHeight(void) { |
return groundPressure - filteredAirPressure; |
} |
|
int16_t analog_getDHeight(void) { |
// dHeight = -dPressure, so here it is the old pressure minus the current, not opposite. |
return lastFilteredAirPressure - filteredAirPressure; |
} |