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

Variable that automaticaly averages itself out when it is set to a value. More...

#include <Util.h>

Public Member Functions

 AvgVar (int samples)
 Construct a new AvgVar given the number of samples to average the value over.
 
 operator T () const
 Cast to the internal average to type T.
 
operator= (T val)
 Update the internal average value given the next value.
 

Detailed Description

template<typename T>
class AvgVar< T >

Variable that automaticaly averages itself out when it is set to a value.

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 63 of file Util.h.

Constructor & Destructor Documentation

◆ AvgVar()

template<typename T >
AvgVar< T >::AvgVar ( int  samples)
inline

Construct a new AvgVar given the number of samples to average the value over.

Parameters
samplesThe number of samples

Definition at line 74 of file Util.h.

Member Function Documentation

◆ operator T()

template<typename T >
AvgVar< T >::operator T ( ) const
inline

Cast to the internal average to type T.

Returns
T The internal average interpreted as type T

Definition at line 83 of file Util.h.

◆ operator=()

template<typename T >
T AvgVar< T >::operator= ( val)
inline

Update the internal average value given the next value.

Parameters
valThe value to update the average with
Returns
T The internal average interpreted as type T

Definition at line 91 of file Util.h.


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