test

Dependencies:   HIDScope MODSERIAL mbed-dsp mbed

Fork of emg_filter2 by BMT M9 Groep01

Committer:
s1340735
Date:
Mon Oct 20 17:59:08 2014 +0000
Revision:
60:7b5ca1a4d7c3
Parent:
28:2d1c7d7635d0
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
s1340735 28:2d1c7d7635d0 1 /* Copyright (c) <2012> MIT License
s1340735 28:2d1c7d7635d0 2 *
s1340735 28:2d1c7d7635d0 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
s1340735 28:2d1c7d7635d0 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
s1340735 28:2d1c7d7635d0 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
s1340735 28:2d1c7d7635d0 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
s1340735 28:2d1c7d7635d0 7 * furnished to do so, subject to the following conditions:
s1340735 28:2d1c7d7635d0 8 *
s1340735 28:2d1c7d7635d0 9 * The above copyright notice and this permission notice shall be included in all copies or
s1340735 28:2d1c7d7635d0 10 * substantial portions of the Software.
s1340735 28:2d1c7d7635d0 11 *
s1340735 28:2d1c7d7635d0 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
s1340735 28:2d1c7d7635d0 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
s1340735 28:2d1c7d7635d0 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
s1340735 28:2d1c7d7635d0 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
s1340735 28:2d1c7d7635d0 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
s1340735 28:2d1c7d7635d0 17 *
s1340735 28:2d1c7d7635d0 18 * @section DESCRIPTION
s1340735 28:2d1c7d7635d0 19 *
s1340735 28:2d1c7d7635d0 20 * 10-Point Moving Average Filter
s1340735 28:2d1c7d7635d0 21 */
s1340735 28:2d1c7d7635d0 22
s1340735 28:2d1c7d7635d0 23 #include "MAF.h"
s1340735 28:2d1c7d7635d0 24
s1340735 28:2d1c7d7635d0 25 MAF::MAF(){}
s1340735 28:2d1c7d7635d0 26
s1340735 28:2d1c7d7635d0 27 float MAF::update(float data){
s1340735 28:2d1c7d7635d0 28
s1340735 28:2d1c7d7635d0 29 _k[0] = data;
s1340735 28:2d1c7d7635d0 30 _result = _k[0]*0.1 + _k[1]*0.1 + _k[2]*0.1 + _k[3]*0.1 + _k[4]*0.1 + _k[5]*0.1 + _k[6]*0.1 + _k[7]*0.1 + _k[8]*0.1 + _k[9]*0.1 ;
s1340735 28:2d1c7d7635d0 31 _k[9] = _k[8];
s1340735 28:2d1c7d7635d0 32 _k[8] = _k[7];
s1340735 28:2d1c7d7635d0 33 _k[7] = _k[6];
s1340735 28:2d1c7d7635d0 34 _k[6] = _k[5];
s1340735 28:2d1c7d7635d0 35 _k[5] = _k[4];
s1340735 28:2d1c7d7635d0 36 _k[4] = _k[3];
s1340735 28:2d1c7d7635d0 37 _k[3] = _k[2];
s1340735 28:2d1c7d7635d0 38 _k[2] = _k[1];
s1340735 28:2d1c7d7635d0 39 _k[1] = _k[0];
s1340735 28:2d1c7d7635d0 40
s1340735 28:2d1c7d7635d0 41 return _result;
s1340735 28:2d1c7d7635d0 42 }
s1340735 28:2d1c7d7635d0 43
s1340735 28:2d1c7d7635d0 44 int MAF::updateInt(int data){
s1340735 28:2d1c7d7635d0 45
s1340735 28:2d1c7d7635d0 46 _a[0] = data;
s1340735 28:2d1c7d7635d0 47 _result = _a[0]*0.1 + _a[1]*0.1 + _a[2]*0.1 + _a[3]*0.1 + _a[4]*0.1 + _a[5]*0.1 + _a[6]*0.1 + _a[7]*0.1 + _a[8]*0.1 + _a[9]*0.1 ;
s1340735 28:2d1c7d7635d0 48 _a[9] = _a[8];
s1340735 28:2d1c7d7635d0 49 _a[8] = _a[7];
s1340735 28:2d1c7d7635d0 50 _a[7] = _a[6];
s1340735 28:2d1c7d7635d0 51 _a[6] = _a[5];
s1340735 28:2d1c7d7635d0 52 _a[5] = _a[4];
s1340735 28:2d1c7d7635d0 53 _a[4] = _a[3];
s1340735 28:2d1c7d7635d0 54 _a[3] = _a[2];
s1340735 28:2d1c7d7635d0 55 _a[2] = _a[1];
s1340735 28:2d1c7d7635d0 56 _a[1] = _a[0];
s1340735 28:2d1c7d7635d0 57
s1340735 28:2d1c7d7635d0 58 return _resultInt;
s1340735 28:2d1c7d7635d0 59 }