|
EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
28 for (
int i =
_order - 1; i > 0; i--) {
33 for (
int i = 0; i <
_order; i++) {
49 for (
int i = 0; i <
_order - 1; i++) {
54 DEBUG_VERBOSE (
"Value: %f\n", value);
56 DEBUG_VERBOSE (
"Raw values:");
57 for (
int i = 0; i <
_order; i++) {
61 DEBUG_VERBOSE (
"Coeffs:");
62 for (
int i = 0; i <
_order; i++) {
74 DEBUG_VERBOSE (
"Index: %d , left: %d , right: %d\n",
_index, left, right);
76 for (
int i = left; i <= right; i++) {
81 DEBUG_VERBOSE (
"Sum: %f", sumValue);
82 DEBUG_VERBOSE (
" SumWeight: %f\n", sumWeight);
84 procValue = sumValue / sumWeight;
86 DEBUG_VERBOSE (
"Average: %f\n", procValue);
102 while (left < right) {
103 while (array[right] > pivot) {
107 while ((left < right) && (array[left] <= pivot)) {
114 array[left] = array[right];
121 array[right] = array[start];
129 for (
int i = 0; i <
_order; i++) {
147 pivot =
divide (array, start, end);
160 int left, right, tempidx;
167 even = ((right - left) % 2) == 1;
168 DEBUG_VERBOSE (
"%d: ", (right - left) % 2);
170 tempidx = (right - left - 1) / 2;
171 DEBUG_VERBOSE (
"even\n");
173 tempidx = (right - left) / 2;
174 DEBUG_VERBOSE (
"odd\n");
176 medianIdx = right -
_index + 1 + tempidx;
182 tempidx = (right - 1) / 2;
185 medianIdx = right -
_index + 1 + tempidx;
187 DEBUG_VERBOSE (
"Index: %d , left: %d , right: %d , even: %s , tempidx: %d , medianidx: %d\n",
_index, left, right, (even ?
"even" :
"odd"), tempidx, medianIdx);
190 for (
int i = 0; i <
_order - 1; i++) {
196 DEBUG_VERBOSE (
"Raw values:");
197 for (
int i = 0; i <
_order; i++) {
202 for (
int i = 0; i <
_order; i++) {
209 DEBUG_VERBOSE (
"Ordered values:");
210 for (
int i = 0; i <
_order; i++) {
221 DEBUG_VERBOSE (
"Median: %f\n", procValue);
237 for (
int i = 0; i <
_order; i++) {
242 for (
int i = 0; i <
_order; i++) {
247 for (
int i = 0; i <
_order; i++) {
float medianFilter(float value)
Median filter calculation of next value.
uint8_t _order
Filter order. Numbre of samples to store for calculations.
float addValue(float value)
Pushes a new value for calculation. Until the buffer is filled up to filter order,...
~FilterClass()
Frees up dynamic memory.
FilterClass(FilterType_t type, uint8_t order)
Creates a new filter class.
FilterType_t
Type of filter.
float addWeigth(float coeff)
Adds a new weighting value. It is pushed on the array so latest value will be used for older data.
float aveFilter(float value)
Average filter calculation of next value.
void clear()
Resets state of the filter to an initial value.
void quicksort(float *array, int start, int end)
Sorting function that uses QuickSort algorythm.
float * _orderedValues
Values ordered for median calculation.
int divide(float *array, int start, int end)
Divide function to be used on Quick Sort.
Auxiliary functions for debugging over Serial.
uint _index
Used to point latest entered value while number of values less than order.
float * _weightValues
Weight values for average calculation. By default all them have value of 1 for arithmetic average.
FilterType_t _filterType
Filter type from FilterType_t.
float * _rawValues
Raw values store.
Filter to process message rate or other values.