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: HIDScope MODSERIAL QEI TextLCD mbed
Fork of TotalControlEmg2 by
Diff: Meanvalue.cpp
- Revision:
- 10:897db0bdb2fe
- Parent:
- 9:1655d67d8a53
- Child:
- 13:b01231e0b743
diff -r 1655d67d8a53 -r 897db0bdb2fe Meanvalue.cpp
--- a/Meanvalue.cpp Wed Oct 07 13:48:19 2015 +0000
+++ b/Meanvalue.cpp Wed Oct 07 14:34:55 2015 +0000
@@ -1,8 +1,8 @@
#include "Meanvalue.h"
-//gemiddelde bepalen
+double samples[30] = {};
-double Meanvalue(double y, double &sum, double &ymean, int &a, int delay){
+double Meanvalue(double y, double &sum, int &a, double &ymean, int delay){
sum = sum + y;
a = a + 1;
@@ -18,6 +18,21 @@
return ymean;
}
}
+
+double Meansmooth(double y, int samples_length, double &ymean){
-//double Meansmooth(double y, double &sum, int &a, double &ymean, int delay){
- // }
\ No newline at end of file
+ for ( int n=30 ; n>1 ; n-- ){
+ samples[n] = samples[n-1];
+ }
+
+ samples[1] = y;
+
+ for ( int n=30 ; n>0 ; n-- ){
+ ymean = ymean + samples [n];
+ }
+ ymean = ymean / 30;
+
+ return ymean;
+
+ }
+
\ No newline at end of file
