Livello Serbatoio v0.13
This project realizes a simple device to monitor the water level in a tank.
Loading...
Searching...
No Matches
MedianFilter Class Reference

Median filter manager. More...

Public Member Functions

 MedianFilter (void)
 Default constructor.
 
void begin (const int16_t seed)
 Initializes this instance.
 
int16_t in (const int16_t value)
 Insert a value in the filter.
 
int16_t out (void) const
 Gets the median values.
 

Private Attributes

byte medFilterWin
 Samples number in the sliding window of the filter - usually an odd value.
 
byte medDataPointer
 Central point of the filter sliding window.
 
int16_t data [FILTER_SIZE]
 Array of data ordered by age (Circular buffer).
 
byte sizeMap [FILTER_SIZE]
 Array used to store data locations ordered by size.
 
byte locationMap [FILTER_SIZE]
 Array used to store data locations in the map.
 
byte oldestDataPoint
 Position of the oldest value in the circular buffer.
 

Detailed Description

Median filter manager.

It uses a buffer to store data and compute the median value.

Constructor & Destructor Documentation

◆ MedianFilter()

MedianFilter::MedianFilter ( void )
inline

Default constructor.

Creates and instance of this class.

Member Function Documentation

◆ begin()

void MedianFilter::begin ( const int16_t seed)
inline

Initializes this instance.

Parameters
[in]seedBuffer start value.

◆ in()

int16_t MedianFilter::in ( const int16_t value)
inline

Insert a value in the filter.

Insert the given value in the filter and than computes the median among inserted values.

Parameters
[in]valueThe value to be inserted.
Returns
The median element.

◆ out()

int16_t MedianFilter::out ( void ) const
inline

Gets the median values.

Accesses the buffer position where the median value is stored in O(1).

Returns
The median.

Member Data Documentation

◆ data

int16_t MedianFilter::data[FILTER_SIZE]
private

Array of data ordered by age (Circular buffer).

◆ locationMap

byte MedianFilter::locationMap[FILTER_SIZE]
private

Array used to store data locations in the map.

◆ medDataPointer

byte MedianFilter::medDataPointer
private

Central point of the filter sliding window.

◆ medFilterWin

byte MedianFilter::medFilterWin
private

Samples number in the sliding window of the filter - usually an odd value.

◆ oldestDataPoint

byte MedianFilter::oldestDataPoint
private

Position of the oldest value in the circular buffer.

◆ sizeMap

byte MedianFilter::sizeMap[FILTER_SIZE]
private

Array used to store data locations ordered by size.


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