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:
parent
c8e7850c3d
commit
f47b332b6f
1 changed files with 5 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue