 |
EnigmaIOT
0.9.3
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
29 for (
int i =
_order - 1; i > 0 ; i--) {
34 for (
int i = 0; i <
_order; i++) {
51 for (
int i = 0; i <
_order - 1; i++) {
56 DEBUG_VERBOSE (
"Value: %f\n", value);
58 DEBUG_VERBOSE (
"Raw values:");
59 for (
int i = 0; i <
_order; i++) {
63 DEBUG_VERBOSE (
"Coeffs:");
64 for (
int i = 0; i <
_order; i++) {
77 DEBUG_VERBOSE (
"Index: %d , left: %d , right: %d\n",
_index, left, right);
79 for (
int i = left; i <= right; i++) {
84 DEBUG_VERBOSE (
"Sum: %f", sumValue);
85 DEBUG_VERBOSE (
" SumWeight: %f\n", sumWeight);
87 procValue = sumValue / sumWeight;
89 DEBUG_VERBOSE (
"Average: %f\n", procValue);
100 pivot = array[start];
105 while (left < right) {
106 while (array[right] > pivot) {
110 while ((left < right) && (array[left] <= pivot)) {
117 array[left] = array[right];
124 array[right] = array[start];
132 for (
int i = 0; i <
_order; i++) {
151 pivot =
divide(array, start, end);
166 int left, right, tempidx;
173 even = ((right - left) % 2) == 1;
174 DEBUG_VERBOSE (
"%d: ", (right - left) % 2);
176 tempidx = (right - left - 1) / 2;
177 DEBUG_VERBOSE (
"even\n");
180 tempidx = (right - left) / 2;
181 DEBUG_VERBOSE (
"odd\n");
183 medianIdx = right -
_index + 1 + tempidx;
190 tempidx = (right - 1) / 2;
193 medianIdx = right -
_index + 1 + tempidx;
195 DEBUG_VERBOSE (
"Index: %d , left: %d , right: %d , even: %s , tempidx: %d , medianidx: %d\n",
_index, left, right, (even ?
"even" :
"odd"), tempidx, medianIdx);
198 for (
int i = 0; i <
_order - 1; i++) {
204 DEBUG_VERBOSE (
"Raw values:");
205 for (
int i = 0; i <
_order; i++) {
210 for (
int i = 0; i <
_order; i++) {
217 DEBUG_VERBOSE (
"Ordered values:");
218 for (
int i = 0; i <
_order; i++) {
230 DEBUG_VERBOSE (
"Median: %f\n", procValue);
247 for (
int i = 0; i <
_order; i++) {
252 for (
int i = 0; i <
_order; i++) {
257 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.
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.
Auxiliary functions for debugging over Serial.
float * _rawValues
Raw values store.
Filter to process message rate or other values.