SPQR-Team1-2020/lib/ArduinoPIDLibraryFlavio/MovingAverageFilter.h

25 lines
533 B
C
Raw Normal View History

2020-02-17 19:14:48 +01:00
/*
https://github.com/sebnil/Moving-Avarage-Filter--Arduino-Library-
*/
#ifndef MovingAverageFilter_h
#define MovingAverageFilter_h
#define MAX_DATA_POINTS 20
class MovingAverageFilter
{
public:
//construct without coefs
MovingAverageFilter(unsigned int newDataPointsCount);
float process(float in);
private:
float values[MAX_DATA_POINTS];
int k; // k stores the index of the current array read to create a circular memory through the array
int dataPointsCount;
float out;
int i; // just a loop counter
};
#endif