SoftFilters  0.1.0
Arduino framework and library of software data filters.
MovingAverageFilter< IN_T, OUT_T, INTERNAL_T > Class Template Reference

A filter that outputs the average of a moving window. More...

#include <SoftFilters.h>

Inheritance diagram for MovingAverageFilter< IN_T, OUT_T, INTERNAL_T >:
Collaboration diagram for MovingAverageFilter< IN_T, OUT_T, INTERNAL_T >:

Public Member Functions

 MovingAverageFilter (size_t w_sz)
 Create a moving average filter with the specified window size. More...
 
- Public Member Functions inherited from CachedFilter< IN_T, OUT_T >
 CachedFilter (size_t cap)
 
- Public Member Functions inherited from Filter
bool push (void const *const input, void *const output)
 Push a new data through the filter. More...
 

Protected Member Functions

INTERNAL_T get_sum ()
 
virtual bool refresh (IN_T const *const new_val, IN_T const *const old_val, OUT_T &output) override
 Refresh the output value given the new value added to the cache and the old value removed from the cache. More...
 
- Protected Member Functions inherited from CachedFilter< IN_T, OUT_T >
virtual bool update (void const *const input) override
 Internally update the filter output based on the given input. More...
 
size_t get_capacity ()
 
size_t get_size ()
 
- Protected Member Functions inherited from BaseFilter< IN_T, OUT_T >
virtual void const *const get_output_val_ptr () final
 Push a new data through the filter. More...
 
virtual void copy_to_client (void *const output) final
 Copy the output to client memory.
 

Protected Attributes

INTERNAL_T internal_result
 representing the result in internal type in case the output type does not have the required precision
 
- Protected Attributes inherited from BaseFilter< IN_T, OUT_T >
OUT_T out_val
 Internally managed storage of the output value.
 

Private Attributes

INTERNAL_T sum
 sum of the current cache content
 

Detailed Description

template<typename IN_T, typename OUT_T, typename INTERNAL_T = double>
class MovingAverageFilter< IN_T, OUT_T, INTERNAL_T >

A filter that outputs the average of a moving window.

Template Parameters
IN_TInput data type.
OUT_TOutput data type.
INTERNAL_TThe type used for internal processing. Defaults to double. Any input is first cast to the internal type for processing, whose result is then cast to the output type.

Constructor & Destructor Documentation

◆ MovingAverageFilter()

template<typename IN_T , typename OUT_T , typename INTERNAL_T = double>
MovingAverageFilter< IN_T, OUT_T, INTERNAL_T >::MovingAverageFilter ( size_t  w_sz)
inline

Create a moving average filter with the specified window size.

Parameters
[in]w_szThe window size.

Member Function Documentation

◆ refresh()

template<typename IN_T , typename OUT_T , typename INTERNAL_T = double>
virtual bool MovingAverageFilter< IN_T, OUT_T, INTERNAL_T >::refresh ( IN_T const *const  new_val,
IN_T const *const  old_val,
OUT_T &  output 
)
inlineoverrideprotectedvirtual

Refresh the output value given the new value added to the cache and the old value removed from the cache.

Note
To be differentiated from the CachedFilter::update member function which overrides the BaseFilter::update member function.

Implements CachedFilter< IN_T, OUT_T >.

Reimplemented in MovingVarianceFilter< IN_T, OUT_T, INTERNAL_T >.


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