SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
AvgVarRef< T > Class Template Reference

Variable that automaticaly averages itself out when it is called, that is, it only updates it's average when the variable is used. More...

#include <Util.h>

Public Member Functions

 AvgVarRef (T *pointer, int samples)
 Construct a new AvgVar Ref given the number of samples to average the value over and the pointer to the variable it should reference.
 
 operator T ()
 Update the internal average.
 

Detailed Description

template<typename T>
class AvgVarRef< T >

Variable that automaticaly averages itself out when it is called, that is, it only updates it's average when the variable is used.

Note
The underlying implementation converts everything to a double to maximize precision when averaging
Template Parameters
TThe primitive data type of this variable

Definition at line 105 of file Util.h.

Constructor & Destructor Documentation

◆ AvgVarRef()

template<typename T >
AvgVarRef< T >::AvgVarRef ( T *  pointer,
int  samples 
)
inline

Construct a new AvgVar Ref given the number of samples to average the value over and the pointer to the variable it should reference.

Parameters
pointerThe variable to reference
samplesThe number of samples

Definition at line 118 of file Util.h.

Member Function Documentation

◆ operator T()

template<typename T >
AvgVarRef< T >::operator T ( )
inline

Update the internal average.

Returns
T The internal average interpreted as type T

Definition at line 128 of file Util.h.


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