1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Fix delta for battery filtering

fix
This commit is contained in:
borisbstyle 2016-02-12 10:20:30 +01:00
parent c8e7850c3d
commit f47b332b6f

View file

@ -65,10 +65,14 @@ static void updateBatteryVoltage(void)
{
uint16_t vbatSample;
static filterStatePt1_t vbatFilterState;
static uint32_t previousTime;
uint32_t now;
// store the battery voltage with some other recent battery voltage readings
vbatSample = vbatLatestADC = adcGetChannel(ADC_BATTERY);
float delta = micros() * 0.000001f;
now = micros();
float delta = (now - previousTime) * 0.000001f;
previousTime = now;
vbatSample = filterApplyPt1(vbatSample, &vbatFilterState, VBATT_LPF_FREQ, delta);
vbat = batteryAdcToVoltage(vbatSample);
}