From e2bf38ec1b8785365cb08155fa60a8af69f1e895 Mon Sep 17 00:00:00 2001 From: Konstantin Sharlaimov Date: Sun, 18 Sep 2016 20:10:59 +0300 Subject: [PATCH] Remove caching of dT value from pt1FilterApply4 (#614) --- src/main/common/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/common/filter.c b/src/main/common/filter.c index b689b25ef..2c5c6cd07 100644 --- a/src/main/common/filter.c +++ b/src/main/common/filter.c @@ -46,10 +46,10 @@ float pt1FilterApply4(pt1Filter_t *filter, float input, uint16_t f_cut, float dT // Pre calculate and store RC if (!filter->RC) { filter->RC = 1.0f / ( 2.0f * M_PIf * f_cut ); - filter->dT = dT; } - filter->state = filter->state + filter->dT / (filter->RC + filter->dT) * (input - filter->state); + filter->dT = dT; // cache latest dT for possible use in pt1FilterApply + filter->state = filter->state + dT / (filter->RC + dT) * (input - filter->state); return filter->state; }