Projectkk2glider/issue 3432 jitter filter option (#3452)

* Fixes #3432: radio option added to turn on/off ADC jitter filter (ported from master)

* Gtests fix

* Re #3432: compilation fix

* Re #3432: existing field split to accommodate the new option without the RadioData size change
This commit is contained in:
Damjan Adamic
2016-05-02 19:26:08 +02:00
committed by Bertrand Songis
parent 9924695b1d
commit 97cc58e323
25 changed files with 112 additions and 56 deletions
+3 -3
View File
@@ -1474,7 +1474,7 @@ JitterMeter<uint16_t> avgJitter[NUMBER_ANALOG];
tmr10ms_t jitterResetTime = 0;
#endif
#if defined(VIRTUALINPUTS) && defined(JITTER_FILTER)
#if defined(VIRTUALINPUTS)
#define JITTER_FILTER_STRENGTH 4 // tune this value, bigger value - more filtering (range: 1-5) (see explanation below)
#define ANALOG_SCALE 1 // tune this value, bigger value - more filtering (range: 0-1) (see explanation below)
@@ -1544,7 +1544,7 @@ void getADC()
for (uint8_t x=0; x<NUMBER_ANALOG; x++) {
uint16_t v = getAnalogValue(x) >> (1 - ANALOG_SCALE);
#if defined(VIRTUALINPUTS) && defined(JITTER_FILTER)
#if defined(VIRTUALINPUTS)
// Jitter filter:
// * pass trough any big change directly
// * for small change use Modified moving average (MMA) filter
@@ -1581,7 +1581,7 @@ void getADC()
// * <out> = s_anaFilt[x]
uint16_t previous = s_anaFilt[x] / JITTER_ALPHA;
uint16_t diff = (v > previous) ? (v - previous) : (previous - v);
if (diff < 10 * ANALOG_MULTIPLIER) {
if (!g_eeGeneral.jitterFilter && diff < (10*ANALOG_MULTIPLIER)) { // g_eeGeneral.jitterFilter is inverted, 0 - active
// apply jitter filter
s_anaFilt[x] = (s_anaFilt[x] - previous) + v;
}