a 10-Point moving average filter that can return an int or a float depending on the function used

Dependents:   A-Quad

MAF.cpp

Committer:
KarimAzzouz
Date:
2012-12-26
Revision:
0:c1b48befe066
Child:
1:fbc57eb4e61d

File content as of revision 0:c1b48befe066:

#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;
   }