Open FFBoard
Open source force feedback firmware
FastMovingAverage< T > Class Template Reference

#include <FastAvg.h>

Public Member Functions

 FastMovingAverage (int32_t len=0)
 
 ~FastMovingAverage ()
 
void clear ()
 
getAndReset ()
 
getAverage ()
 
addValue (T v)
 

Private Attributes

curAvg = 0
 
const int32_t fixedLen
 
int32_t count = 0
 

Detailed Description

template<class T>
class FastMovingAverage< T >

Calculates a moving average of variable length Can periodically get and reset a value to average for an unknown amount of data points If len != 0 calculates an exponential moving average with length len. If len = 0 length equals the current amount of samples up to 0x7FFFFFFF.

Definition at line 63 of file FastAvg.h.

Constructor & Destructor Documentation

◆ FastMovingAverage()

template<class T >
FastMovingAverage< T >::FastMovingAverage ( int32_t  len = 0)
inline

Definition at line 65 of file FastAvg.h.

◆ ~FastMovingAverage()

template<class T >
FastMovingAverage< T >::~FastMovingAverage ( )
inline

Definition at line 66 of file FastAvg.h.

Member Function Documentation

◆ addValue()

template<class T >
T FastMovingAverage< T >::addValue ( v)
inline

Adds a value and returns current average

Definition at line 90 of file FastAvg.h.

◆ clear()

template<class T >
void FastMovingAverage< T >::clear ( )
inline

Definition at line 68 of file FastAvg.h.

◆ getAndReset()

template<class T >
T FastMovingAverage< T >::getAndReset ( )
inline

Gets current average and clears current average and counter

Definition at line 75 of file FastAvg.h.

◆ getAverage()

template<class T >
T FastMovingAverage< T >::getAverage ( )
inline

Gets current average without resetting

Definition at line 84 of file FastAvg.h.

Member Data Documentation

◆ count

template<class T >
int32_t FastMovingAverage< T >::count = 0
private

Definition at line 99 of file FastAvg.h.

◆ curAvg

template<class T >
T FastMovingAverage< T >::curAvg = 0
private

Definition at line 97 of file FastAvg.h.

◆ fixedLen

template<class T >
const int32_t FastMovingAverage< T >::fixedLen
private

Definition at line 98 of file FastAvg.h.


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