3-phase PV router
|
Exponentially Weighted Moving Average. More...
#include <ewma_avg.hpp>
Public Member Functions | |
void | addValue (int32_t input) |
Add a new value and actualize the EMA, DEMA and TEMA. | |
auto | getAverageD () const |
Get the DEMA. | |
auto | getAverageS () const |
Get the EMA. | |
auto | getAverageT () const |
Get the TEMA. | |
Private Attributes | |
int32_t | ema { 0 } |
int32_t | ema_ema { 0 } |
int32_t | ema_ema_ema { 0 } |
int32_t | ema_ema_ema_raw { 0 } |
int32_t | ema_ema_raw { 0 } |
int32_t | ema_raw { 0 } |
Exponentially Weighted Moving Average.
The smoothing factor is the approximate amount of values taken to calculate the average. Since the Arduino is very slow and does not provide any dedicated math co-processor, the smoothing factor will be rounded to the previous power of 2. Ie 120 will be rounded to 64. This allows to perform all the calculations with integer math, which is much faster !
A | Smoothing factor |
input | Input value |
Definition at line 77 of file ewma_avg.hpp.
|
inline |
Add a new value and actualize the EMA, DEMA and TEMA.
input | The new value |
Definition at line 85 of file ewma_avg.hpp.
|
inline |
|
inline |
|
inline |
|
private |
Definition at line 133 of file ewma_avg.hpp.
|
private |
Definition at line 131 of file ewma_avg.hpp.
|
private |
Definition at line 129 of file ewma_avg.hpp.
|
private |
Definition at line 128 of file ewma_avg.hpp.
|
private |
Definition at line 130 of file ewma_avg.hpp.
|
private |
Definition at line 132 of file ewma_avg.hpp.