Simple Incremental LPF filter

This commit is contained in:
philsson 2018-08-29 22:45:59 +02:00
parent fe69b7764d
commit a509b29348
2 changed files with 36 additions and 0 deletions

17
src/control/lpf.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "src/control/lpf.h"
namespace control {
incrementalLPF::incrementalLPF()
: m_filtered(0)
{
}
double incrementalLPF::filter(double latestValue)
{
m_filtered = m_filtered*0.95 + latestValue*0.05;
return m_filtered;
}
} // namespace control

19
src/control/lpf.h Normal file
View File

@ -0,0 +1,19 @@
#pragma once
namespace control {
class incrementalLPF
{
public:
incrementalLPF();
double filter(double latestValue);
private:
double m_filtered;
};
} // namespace control