Filter with exponential moving average algorithm. More...
#include <SignalProcessing.hpp>
Public Member Functions | |
| ExponentialFilter () | |
| Constructor for ExponentialFilter. Initializes the last output value to zero. | |
| void | addSample (TypeInput sample) override |
| Adds a new sample to the ExponentialFilter. Updates the filtered value using the exponential moving average formula. | |
| TypeInput | getFiltered () const override |
| Retrieves the filtered value from the ExponentialFilter. | |
| virtual void | addSample (TypeInput sample)=0 |
| virtual TypeInput | getFiltered () const =0 |
Private Attributes | |
| TypeInput | last_out = 0 |
Filter with exponential moving average algorithm.
Old samples "decay" naturally. The formula used is: f(t) = (f(t-1) * OLD_RATIO + sample * NEW_RATIO + (OLD_RATIO + NEW_RATIO) / 2) / (OLD_RATIO + NEW_RATIO) Due to round down, the results won't ever reach maximum, especially if OLD_RATIO >> NEW_RATIO, so the use of curve is important.
| TypeInput | Type of the input samples. |
| TypeMid | Type used for intermediate calculations. |
| OLD_RATIO | Weighting ratio for the old value. |
| NEW_RATIO | Weighting ratio for the new sample. |
Definition at line 59 of file SignalProcessing.hpp.
|
default |
Constructor for ExponentialFilter. Initializes the last output value to zero.
| TypeInput | Type of the input samples. |
| TypeMid | Type used for intermediate calculations. |
| OLD_RATIO | Weighting ratio for the old value. |
| NEW_RATIO | Weighting ratio for the new sample. |
|
overridevirtual |
Adds a new sample to the ExponentialFilter. Updates the filtered value using the exponential moving average formula.
| TypeInput | Type of the input samples. |
| TypeMid | Type used for intermediate calculations. |
| OLD_RATIO | Weighting ratio for the old value. |
| NEW_RATIO | Weighting ratio for the new sample. |
| sample | New input sample to add. |
Implements Filter< TypeInput, TypeMid >.
Definition at line 81 of file SignalProcessing.tpp.
Referenced by Pedal::update().
|
overridevirtual |
Retrieves the filtered value from the ExponentialFilter.
| TypeInput | Type of the input samples. |
| TypeMid | Type used for intermediate calculations. |
| OLD_RATIO | Weighting ratio for the old value. |
| NEW_RATIO | Weighting ratio for the new sample. |
Implements Filter< TypeInput, TypeMid >.
Definition at line 95 of file SignalProcessing.tpp.
Referenced by Pedal::sendFrame().
|
private |
Last output value for exponential filter, input for next calculation
Definition at line 67 of file SignalProcessing.hpp.