EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FilterClass Class Reference

#include <Filter.h>

Public Member Functions

 FilterClass (FilterType_t type, uint8_t order)
 Creates a new filter class. More...
 
float addWeigth (float coeff)
 Adds a new weighting value. It is pushed on the array so latest value will be used for older data. More...
 
float addValue (float value)
 Pushes a new value for calculation. Until the buffer is filled up to filter order, only first valid values are used in calculation. More...
 
void clear ()
 Resets state of the filter to an initial value. More...
 
 ~FilterClass ()
 Frees up dynamic memory. More...
 

Protected Member Functions

float aveFilter (float value)
 Average filter calculation of next value. More...
 
int divide (float *array, int start, int end)
 Divide function to be used on Quick Sort. More...
 
void quicksort (float *array, int start, int end)
 Sorting function that uses QuickSort algorythm. More...
 
float medianFilter (float value)
 Median filter calculation of next value. More...
 

Protected Attributes

FilterType_t _filterType
 Filter type from FilterType_t. More...
 
uint8_t _order
 Filter order. Numbre of samples to store for calculations. More...
 
float * _rawValues
 Raw values store. More...
 
float * _orderedValues
 Values ordered for median calculation. More...
 
float * _weightValues
 Weight values for average calculation. By default all them have value of 1 for arithmetic average. More...
 
uint _index = 0
 Used to point latest entered value while number of values less than order. More...
 

Detailed Description

Definition at line 29 of file Filter.h.

Constructor & Destructor Documentation

◆ FilterClass()

FilterClass::FilterClass ( FilterType_t  type,
uint8_t  order 
)

Creates a new filter class.

Parameters
typeFilter type from FilterType_t
orderFilter order

Definition at line 225 of file Filter.cpp.

◆ ~FilterClass()

FilterClass::~FilterClass ( )

Frees up dynamic memory.

Definition at line 137 of file Filter.cpp.

Member Function Documentation

◆ addValue()

float FilterClass::addValue ( float  value)

Pushes a new value for calculation. Until the buffer is filled up to filter order, only first valid values are used in calculation.

Parameters
valueNext value
Returns
Weighted average value

Definition at line 12 of file Filter.cpp.

◆ addWeigth()

float FilterClass::addWeigth ( float  coeff)

Adds a new weighting value. It is pushed on the array so latest value will be used for older data.

Parameters
coeffNext weighting coefficient
Returns
Sum of all weighting values

Definition at line 25 of file Filter.cpp.

◆ aveFilter()

float FilterClass::aveFilter ( float  value)
protected

Average filter calculation of next value.

Parameters
valueNext value to do calculation with
Returns
Returns calculated average (weighted or unweighted)

Definition at line 43 of file Filter.cpp.

◆ clear()

void FilterClass::clear ( )

Resets state of the filter to an initial value.

Definition at line 128 of file Filter.cpp.

◆ divide()

int FilterClass::divide ( float *  array,
int  start,
int  end 
)
protected

Divide function to be used on Quick Sort.

Parameters
arrayInput array
startStart index
endEnd index
Returns
Returns new pivot position

Definition at line 91 of file Filter.cpp.

◆ medianFilter()

float FilterClass::medianFilter ( float  value)
protected

Median filter calculation of next value.

Parameters
valueNext value to do calculation with
Returns
Returns calculated median

Definition at line 157 of file Filter.cpp.

◆ quicksort()

void FilterClass::quicksort ( float *  array,
int  start,
int  end 
)
protected

Sorting function that uses QuickSort algorythm.

Parameters
arrayInput array
startStart index
endEnd index

Definition at line 143 of file Filter.cpp.

Member Data Documentation

◆ _filterType

FilterType_t FilterClass::_filterType
protected

Filter type from FilterType_t.

Definition at line 31 of file Filter.h.

◆ _index

uint FilterClass::_index = 0
protected

Used to point latest entered value while number of values less than order.

Definition at line 36 of file Filter.h.

◆ _order

uint8_t FilterClass::_order
protected

Filter order. Numbre of samples to store for calculations.

Definition at line 32 of file Filter.h.

◆ _orderedValues

float* FilterClass::_orderedValues
protected

Values ordered for median calculation.

Definition at line 34 of file Filter.h.

◆ _rawValues

float* FilterClass::_rawValues
protected

Raw values store.

Definition at line 33 of file Filter.h.

◆ _weightValues

float* FilterClass::_weightValues
protected

Weight values for average calculation. By default all them have value of 1 for arithmetic average.

Definition at line 35 of file Filter.h.


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