Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: biquadFilter mbed
Diff: calibrate.cpp
- Revision:
- 4:4de31fc4f912
- Parent:
- 3:082ba262d2ec
--- a/calibrate.cpp Thu Nov 03 08:46:55 2016 +0000 +++ b/calibrate.cpp Thu Nov 03 09:19:45 2016 +0000 @@ -46,6 +46,7 @@ float calibrateEmgCache2[calibrateNumEmgCache]; //sorted from new to old; // ARRAYS USED IN CALCULATION OF THE MOVAG +// Values in these arrays contain samples that are already notched and rectified. const int numEmgCache = 50; float emgCache1[numEmgCache]; //sorted from new to old; float emgCache2[numEmgCache]; //sorted from new to old; @@ -95,16 +96,6 @@ array[0] = newValue; } -float average(float newValue, float array[], int size) { - float sum = 0; - for (int i = size - 2; i >= 0; i--) { - sum += array[i]; - } - // array[0] = newValue; - sum += newValue; - return sum / size; -} - //shifts the array by adding the new emg value up front. //returns the new calculated average float movingAverage(float newValue, float array[], int size) { @@ -244,8 +235,8 @@ float filtered1 = movingAverage( rect1, emgCache1, numEmgCache); float filtered2 = movingAverage( rect2, emgCache2, numEmgCache); - int decide1 = decide(average(filtered1, emgCache1, numEmgCache ), threshold1); - int decide2 = decide(average(filtered2, emgCache2, numEmgCache ), threshold2); + int decide1 = decide(mean(emgCache1, numEmgCache ), threshold1); + int decide2 = decide(mean(emgCache2, numEmgCache ), threshold2); addFirst(decide1, decided1, numEmgCache); addFirst(decide2, decided2, numEmgCache); @@ -256,7 +247,7 @@ scope.set(3,decide2); } - if (count >= 50) { + if (count >= 49) { int counter1=0; int counter2=0; for(int i = 0; i < numEmgCache; ++i){