3-phase PV router
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
EWMA_average< A > Class Template Reference

Exponentially Weighted Moving Average. More...

#include <ewma_avg.hpp>

Inheritance diagram for EWMA_average< A >:
Inheritance graph
[legend]

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 }
 

Detailed Description

template<uint8_t A = 10>
class EWMA_average< A >

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 !

Note
Because of the 'sign extension', the sign is copied into lower bits.
Template Parameters
ASmoothing factor
Parameters
inputInput value
Returns
long Output value

Definition at line 77 of file ewma_avg.hpp.

Member Function Documentation

◆ addValue()

template<uint8_t A = 10>
void EWMA_average< A >::addValue ( int32_t  input)
inline

Add a new value and actualize the EMA, DEMA and TEMA.

Parameters
inputThe new value

Definition at line 85 of file ewma_avg.hpp.

Here is the call graph for this function:

◆ getAverageD()

template<uint8_t A = 10>
auto EWMA_average< A >::getAverageD ( ) const
inline

Get the DEMA.

Returns
auto The DEMA value

Definition at line 112 of file ewma_avg.hpp.

◆ getAverageS()

template<uint8_t A = 10>
auto EWMA_average< A >::getAverageS ( ) const
inline

Get the EMA.

Returns
auto The EMA value

Definition at line 102 of file ewma_avg.hpp.

◆ getAverageT()

template<uint8_t A = 10>
auto EWMA_average< A >::getAverageT ( ) const
inline

Get the TEMA.

Returns
auto The TEMA value

Definition at line 122 of file ewma_avg.hpp.

Member Data Documentation

◆ ema

template<uint8_t A = 10>
int32_t EWMA_average< A >::ema { 0 }
private

Definition at line 133 of file ewma_avg.hpp.

◆ ema_ema

template<uint8_t A = 10>
int32_t EWMA_average< A >::ema_ema { 0 }
private

Definition at line 131 of file ewma_avg.hpp.

◆ ema_ema_ema

template<uint8_t A = 10>
int32_t EWMA_average< A >::ema_ema_ema { 0 }
private

Definition at line 129 of file ewma_avg.hpp.

◆ ema_ema_ema_raw

template<uint8_t A = 10>
int32_t EWMA_average< A >::ema_ema_ema_raw { 0 }
private

Definition at line 128 of file ewma_avg.hpp.

◆ ema_ema_raw

template<uint8_t A = 10>
int32_t EWMA_average< A >::ema_ema_raw { 0 }
private

Definition at line 130 of file ewma_avg.hpp.

◆ ema_raw

template<uint8_t A = 10>
int32_t EWMA_average< A >::ema_raw { 0 }
private

Definition at line 132 of file ewma_avg.hpp.


The documentation for this class was generated from the following file: