Red Bird Racing VCU v2
 
Loading...
Searching...
No Matches
AverageFilter< TypeInput, TypeMid, SIZE > Class Template Reference

Filter with simple moving average algorithm. More...

#include <SignalProcessing.hpp>

Inheritance diagram for AverageFilter< TypeInput, TypeMid, SIZE >:
Collaboration diagram for AverageFilter< TypeInput, TypeMid, SIZE >:

Public Member Functions

 AverageFilter ()
 Constructor for AverageFilter. Initializes the circular buffer to zero.
 
void addSample (TypeInput sample) override
 Adds a new sample to the AverageFilter. Stores the sample in the circular buffer and updates the index.
 
TypeInput getFiltered () const override
 Retrieves the filtered value from the AverageFilter. Computes the average of the samples in the circular buffer.
 
virtual void addSample (TypeInput sample)=0
 
virtual TypeInput getFiltered () const =0
 

Private Attributes

TypeInput buffer [SIZE]
 
uint16_t index = 0
 

Detailed Description

template<typename TypeInput, typename TypeMid, uint16_t SIZE>
class AverageFilter< TypeInput, TypeMid, SIZE >

Filter with simple moving average algorithm.

Template Parameters
TypeInputType of the input samples.
TypeMidType used for intermediate calculations.
SIZENumber of samples to average over.

Definition at line 36 of file SignalProcessing.hpp.

Constructor & Destructor Documentation

◆ AverageFilter()

template<typename TypeInput , typename TypeMid , uint16_t SIZE>
AverageFilter< TypeInput, TypeMid, SIZE >::AverageFilter ( )
default

Constructor for AverageFilter. Initializes the circular buffer to zero.

Template Parameters
TypeInputType of the input samples.
TypeMidType used for intermediate calculations.
SIZENumber of samples to average over.

Member Function Documentation

◆ addSample()

template<typename TypeInput , typename TypeMid , uint16_t SIZE>
void AverageFilter< TypeInput, TypeMid, SIZE >::addSample ( TypeInput  sample)
overridevirtual

Adds a new sample to the AverageFilter. Stores the sample in the circular buffer and updates the index.

Template Parameters
TypeInputType of the input samples.
TypeMidType used for intermediate calculations.
SIZENumber of samples to average over.
Parameters
sampleNew input sample to add.

Implements Filter< TypeInput, TypeMid >.

Definition at line 33 of file SignalProcessing.tpp.

◆ getFiltered()

template<typename TypeInput , typename TypeMid , uint16_t SIZE>
TypeInput AverageFilter< TypeInput, TypeMid, SIZE >::getFiltered
overridevirtual

Retrieves the filtered value from the AverageFilter. Computes the average of the samples in the circular buffer.

Template Parameters
TypeInputType of the input samples.
TypeMidType used for intermediate calculations.
SIZENumber of samples to average over.
Returns
Filtered average value.

Implements Filter< TypeInput, TypeMid >.

Definition at line 48 of file SignalProcessing.tpp.

Member Data Documentation

◆ buffer

template<typename TypeInput , typename TypeMid , uint16_t SIZE>
TypeInput AverageFilter< TypeInput, TypeMid, SIZE >::buffer[SIZE]
private

Circular buffer for storing samples

Definition at line 44 of file SignalProcessing.hpp.

◆ index

template<typename TypeInput , typename TypeMid , uint16_t SIZE>
uint16_t AverageFilter< TypeInput, TypeMid, SIZE >::index = 0
private

Current index in the circular buffer

Definition at line 45 of file SignalProcessing.hpp.


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