41,8 → 41,8 |
/* |
* Airspeed |
*/ |
int16_t airpressure; |
uint16_t airspeedVelocity = 0; |
//int16_t airpressure; |
//uint16_t airspeedVelocity = 0; |
//int16_t airpressureWindow[AIRPRESSURE_WINDOW_LENGTH]; |
//uint8_t airpressureWindowIdx = 0; |
|
131,7 → 131,7 |
|
// ADC channels |
#define AD_UBAT 6 |
#define AD_AIRPRESSURE 7 |
//#define AD_AIRPRESSURE 7 |
|
/* |
* Table of AD converter inputs for each state. |
146,11 → 146,11 |
*/ |
|
const uint8_t channelsForStates[] PROGMEM = { |
AD_AIRPRESSURE, |
AD_UBAT, |
AD_AIRPRESSURE, |
AD_AIRPRESSURE, |
AD_AIRPRESSURE, |
//AD_AIRPRESSURE, |
AD_UBAT |
//AD_AIRPRESSURE, |
//AD_AIRPRESSURE, |
//AD_AIRPRESSURE, |
}; |
|
// Feature removed. Could be reintroduced later - but should work for all gyro types then. |
218,7 → 218,7 |
} |
|
adState = 0; |
adChannel = AD_AIRPRESSURE; |
adChannel = AD_UBAT; |
ADMUX = (ADMUX & 0xE0) | adChannel; |
startADC(); |
sensorDataReady = 0; |
300,12 → 300,13 |
} |
} |
|
/* |
// probably wanna aim at 1/10 m/s/unit. |
#define LOG_AIRSPEED_FACTOR 0 |
|
void analog_updateAirspeed(void) { |
uint16_t rawAirpressure = ADSensorInputs[AD_AIRPRESSURE]; |
int16_t temp = rawAirpressure - airpressureOffset; |
int16_t temp = airpressureOffset - rawAirPressure; |
// airpressure -= airpressureWindow[airpressureWindowIdx]; |
// airpressure += temp; |
// airpressureWindow[airpressureWindowIdx] = temp; |
326,6 → 327,7 |
|
isFlying = 0; //(airspeedVelocity >= staticParams.isFlyingThreshold); |
} |
*/ |
|
void analog_updateBatteryVoltage(void) { |
// Battery. The measured value is: (V * 1k/11k)/3v * 1024 = 31.03 counts per volt (max. measurable is 33v). |
336,7 → 338,7 |
void analog_update(void) { |
analog_updateGyros(); |
// analog_updateAccelerometers(); |
analog_updateAirspeed(); |
// analog_updateAirspeed(); |
analog_updateBatteryVoltage(); |
#ifdef USE_MK3MAG |
magneticHeading = volatileMagneticHeading; |
379,7 → 381,7 |
for (axis = PITCH; axis <= YAW; axis++) { |
offsets[axis] += rawGyroValue(axis); |
} |
offsets[3] += ADSensorInputs[AD_AIRPRESSURE]; |
// offsets[3] += ADSensorInputs[AD_AIRPRESSURE]; |
} |
|
for (axis = PITCH; axis <= YAW; axis++) { |
386,6 → 388,7 |
gyroOffset.offsets[axis] = (offsets[axis] + OFFSET_CYCLES / 2) / OFFSET_CYCLES; |
} |
|
/* |
airpressureOffset = (offsets[3] + OFFSET_CYCLES / 2) / OFFSET_CYCLES; |
int16_t min = 200; |
int16_t max = 1024-200; |
392,8 → 395,10 |
|
if(airpressureOffset < min || airpressureOffset > max) |
versionInfo.hardwareErrors[0] |= FC_ERROR0_PRESSURE; |
*/ |
|
gyroOffset_writeToEEProm(); |
airpressureOffset_writeToEEProm(); |
|
startAnalogConversionCycle(); |
} |