PicoLowLevel
Loading...
Searching...
No Matches
ExpSmoothingFilter.h
Go to the documentation of this file.
1#ifndef EXP_SMOOTHING_FILTER_H
2#define EXP_SMOOTHING_FILTER_H
3
4#include "Filter.h"
5
10template<typename T>
11class ExpSmoothingFilter: public Filter<T> {
12 public:
19 ExpSmoothingFilter(int a, int b) {
20 this->a = a;
21 this->b = b;
22 previous = 0;
23 }
24
30 T filter(T value) {
31 return previous = (value*a + previous*(b-a))/b;
32 }
33
34 private:
35 T previous;
36 int a, b;
37};
38
39#endif
Class for a exponential smoothing filter implementing the Filter interface.
Definition ExpSmoothingFilter.h:11
ExpSmoothingFilter(int a, int b)
Constructor for the exponential smoothing filter.
Definition ExpSmoothingFilter.h:19
T filter(T value)
Computes the filtered output using an exponential filter, giving the passed value a weight of a/b.
Definition ExpSmoothingFilter.h:30
Interface for a generic filter, with parameterized type.
Definition Filter.h:9