Sylib
A C++ Library For V5
Loading...
Searching...
No Matches
sylib::SMAFilter Class Reference

Simple Moving Average Filter. More...

#include <math.hpp>

Public Member Functions

 SMAFilter (int sampleSize)
 Creates a Simple Moving Average filter. More...
 
double filter (double rawValue)
 Filters an input value. More...
 
int getQueueLength () const
 Gets the current length of the queue of previous values. More...
 
int getQueueMaxLength () const
 Gets the maximum length of the queue of previous values. More...
 
double getCurrentTotal () const
 Gets the current sum of queue values. More...
 
double getCurrentValue () const
 Gets the current filter output without providing a new input value. More...
 

Detailed Description

Simple Moving Average Filter.

Constructor & Destructor Documentation

◆ SMAFilter()

sylib::SMAFilter::SMAFilter ( int  sampleSize)

Creates a Simple Moving Average filter.

Parameters
sampleSizeThe number of previous values to average. A higher number will result in a more stable value, but with more lag.

Member Function Documentation

◆ filter()

double sylib::SMAFilter::filter ( double  rawValue)

Filters an input value.

Parameters
rawValueThe raw input value to filter
Returns
Filter output

◆ getCurrentTotal()

double sylib::SMAFilter::getCurrentTotal ( ) const

Gets the current sum of queue values.

Returns
Sum of values

◆ getCurrentValue()

double sylib::SMAFilter::getCurrentValue ( ) const

Gets the current filter output without providing a new input value.

Returns
Filter output

◆ getQueueLength()

int sylib::SMAFilter::getQueueLength ( ) const

Gets the current length of the queue of previous values.

Returns
Queue length

◆ getQueueMaxLength()

int sylib::SMAFilter::getQueueMaxLength ( ) const

Gets the maximum length of the queue of previous values.

Equal to the sample size specifiied in the constructor

Returns
Max sample size