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
Meanvalue.cpp
- Committer:
- Bartvaart
- Date:
- 2015-10-09
- Revision:
- 15:c1a8f28d6583
- Parent:
- 13:b01231e0b743
File content as of revision 15:c1a8f28d6583:
#include "Meanvalue.h"
double samples[30] = {};
double Meanvalue(double y, double &sum, int &a, double &ymean, int delay){
sum = sum + y;
a = a + 1;
if (a == delay)
{
double ymean = sum / a;
sum = 0;
a = 0;
return ymean;
}
else{
return ymean;
}
}
double Meansmooth(double y, int samples_length, double &ymean){
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;
}
