Browse Source

sns: default to SumFilter when counting values

Simplify fix for:
https://gitter.im/tinkerman-cat/espurna?at=5f6661a1f969413294f7404d

Most of the time, we care about the sum during report interval, not the
value that gets aggregated across all readings
mcspr-patch-1
Maxim Prokhorov 4 years ago
committed by Max Prokhorov
parent
commit
7dd8594a26
1 changed files with 3 additions and 22 deletions
  1. +3
    -22
      code/espurna/sensor.cpp

+ 3
- 22
code/espurna/sensor.cpp View File

@ -520,18 +520,15 @@ BaseFilter* _magnitudeCreateFilter(unsigned char type, size_t size) {
case MAGNITUDE_ENERGY:
filter = new LastFilter();
break;
case MAGNITUDE_COUNT:
case MAGNITUDE_GEIGER_CPM:
case MAGNITUDE_GEIGER_SIEVERT:
case MAGNITUDE_ENERGY_DELTA:
filter = new SumFilter();
break;
case MAGNITUDE_DIGITAL:
filter = new MaxFilter();
break;
// For geiger counting moving average filter is the most appropriate if needed at all.
case MAGNITUDE_COUNT:
case MAGNITUDE_GEIGER_CPM:
case MAGNITUDE_GEIGER_SIEVERT:
filter = new MovingAverageFilter();
break;
default:
filter = new MedianFilter();
break;
@ -2752,24 +2749,8 @@ void sensorLoop() {
}
magnitude.last = value_raw;
// -------------------------------------------------------------
// Processing (filters)
// -------------------------------------------------------------
magnitude.filter->add(value_raw);
// Special case for MovingAverageFilter
switch (magnitude.type) {
case MAGNITUDE_COUNT:
case MAGNITUDE_GEIGER_CPM:
case MAGNITUDE_GEIGER_SIEVERT:
value_raw = magnitude.filter->result();
break;
default:
break;
}
// -------------------------------------------------------------
// Procesing (units and decimals)
// -------------------------------------------------------------


Loading…
Cancel
Save