EnigmaIOT  0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
Filter.h
Go to the documentation of this file.
1 
9 #ifndef _FILTER_h
10 #define _FILTER_h
11 
12 #if defined(ARDUINO) && ARDUINO >= 100
13 #include "Arduino.h"
14 #else
15 #include "WProgram.h"
16 #endif
17 
18 #define MAX_ORDER 20
19 #define MIN_ORDER 2
20 
24 typedef enum {
28 
29 class FilterClass {
30 protected:
32  uint8_t _order;
33  float* _rawValues;
34  float* _orderedValues;
35  float* _weightValues;
36  uint _index = 0;
37 
43  float aveFilter (float value);
44 
52  int divide (float* array, int start, int end);
53 
60  void quicksort (float* array, int start, int end);
61 
67  float medianFilter (float value);
68 
69 public:
75  FilterClass (FilterType_t type, uint8_t order);
76 
82  float addWeigth (float coeff);
83 
89  float addValue (float value);
90 
94  void clear ();
95 
99  ~FilterClass ();
100 };
101 
102 #endif
103 
FilterClass::medianFilter
float medianFilter(float value)
Median filter calculation of next value.
Definition: Filter.cpp:157
FilterClass::_order
uint8_t _order
Filter order. Numbre of samples to store for calculations.
Definition: Filter.h:32
MEDIAN_FILTER
@ MEDIAN_FILTER
Definition: Filter.h:25
FilterClass::addValue
float addValue(float value)
Pushes a new value for calculation. Until the buffer is filled up to filter order,...
Definition: Filter.cpp:12
FilterClass::~FilterClass
~FilterClass()
Frees up dynamic memory.
Definition: Filter.cpp:137
FilterClass
Definition: Filter.h:29
FilterClass::FilterClass
FilterClass(FilterType_t type, uint8_t order)
Creates a new filter class.
Definition: Filter.cpp:225
FilterType_t
FilterType_t
Type of filter.
Definition: Filter.h:24
FilterClass::addWeigth
float addWeigth(float coeff)
Adds a new weighting value. It is pushed on the array so latest value will be used for older data.
Definition: Filter.cpp:25
FilterClass::aveFilter
float aveFilter(float value)
Average filter calculation of next value.
Definition: Filter.cpp:43
FilterClass::clear
void clear()
Resets state of the filter to an initial value.
Definition: Filter.cpp:128
FilterClass::quicksort
void quicksort(float *array, int start, int end)
Sorting function that uses QuickSort algorythm.
Definition: Filter.cpp:143
FilterClass::_orderedValues
float * _orderedValues
Values ordered for median calculation.
Definition: Filter.h:34
FilterClass::divide
int divide(float *array, int start, int end)
Divide function to be used on Quick Sort.
Definition: Filter.cpp:91
FilterClass::_index
uint _index
Used to point latest entered value while number of values less than order.
Definition: Filter.h:36
FilterClass::_weightValues
float * _weightValues
Weight values for average calculation. By default all them have value of 1 for arithmetic average.
Definition: Filter.h:35
FilterClass::_filterType
FilterType_t _filterType
Filter type from FilterType_t.
Definition: Filter.h:31
AVERAGE_FILTER
@ AVERAGE_FILTER
Definition: Filter.h:26
FilterClass::_rawValues
float * _rawValues
Raw values store.
Definition: Filter.h:33