a 10-Point moving average filter that can return an int or a float depending on the function used
Diff: MAF.cpp
- Revision:
- 0:c1b48befe066
- Child:
- 1:fbc57eb4e61d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MAF.cpp Wed Dec 26 10:44:34 2012 +0000 @@ -0,0 +1,20 @@ +#include "MAF.h" + + MAF::MAF(){ + _result = 0; + _k[0]=0 ; + _k[1]=0 ; + _k[2]=0 ; + _k[3]=0 ; + } + + float MAF::update(float data){ + + _k[0] = data; + _result = _k[0]*0.25 + _k[1]*0.25 + _k[2]*0.25 + _k[3]*0.25; + _k[3] = _k[2]; + _k[2] = _k[1]; + _k[1] = _k[0]; + + return _result; + } \ No newline at end of file