Alle drie de signalen gefilterd en binair gemaakt
Dependencies: mbed HIDScope biquadFilter
MAF.cpp@21:f6e70856810c, 2019-10-29 (annotated)
- Committer:
- Feike
- Date:
- Tue Oct 29 14:48:30 2019 +0000
- Revision:
- 21:f6e70856810c
Werkend filter met Butterworth en mean averaging
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Feike | 21:f6e70856810c | 1 | #include "MAF.h" |
Feike | 21:f6e70856810c | 2 | |
Feike | 21:f6e70856810c | 3 | MAF::MAF() |
Feike | 21:f6e70856810c | 4 | {} |
Feike | 21:f6e70856810c | 5 | |
Feike | 21:f6e70856810c | 6 | float MAF::update(float data) |
Feike | 21:f6e70856810c | 7 | { |
Feike | 21:f6e70856810c | 8 | int L = 20; |
Feike | 21:f6e70856810c | 9 | float result = 0; |
Feike | 21:f6e70856810c | 10 | _k[0] = data; |
Feike | 21:f6e70856810c | 11 | for(int i=0; i<L; i++) |
Feike | 21:f6e70856810c | 12 | { |
Feike | 21:f6e70856810c | 13 | result = result + _k[i]*1.0/L; |
Feike | 21:f6e70856810c | 14 | } |
Feike | 21:f6e70856810c | 15 | |
Feike | 21:f6e70856810c | 16 | for (int j=L-1; j>=0; j--) |
Feike | 21:f6e70856810c | 17 | { |
Feike | 21:f6e70856810c | 18 | _k[j] = _k[j-1]; |
Feike | 21:f6e70856810c | 19 | } |
Feike | 21:f6e70856810c | 20 | |
Feike | 21:f6e70856810c | 21 | return _result; |
Feike | 21:f6e70856810c | 22 | } |