![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
script zover
Dependencies: HIDScope MODSERIAL mbed
Diff: main.cpp
- Revision:
- 1:bc2db3bff4bb
- Parent:
- 0:bed29da02e8b
- Child:
- 2:620ff9f02d62
--- a/main.cpp Mon Oct 13 10:44:50 2014 +0000 +++ b/main.cpp Mon Oct 13 11:02:05 2014 +0000 @@ -6,6 +6,8 @@ #define A0HP 0.999214978283642 #define B1HP -1.943446330323158 #define B0HP 0.945001709500376 +#define TSAMP 0.01 + AnalogIn emg0(PTB1); MODSERIAL pc(USBTX,USBRX); @@ -14,12 +16,12 @@ float filter(float); float emg_value; static float y,x1=0,y1=0,x2=0,y2=0; - +volatile bool looptimerflag; void read() { - emg_value=emg0.read_u16(); + emg_value=emg0.read_u16(); } float filter(float emg0_value) @@ -39,13 +41,21 @@ scope.send(); } +void setlooptimerflag(void) +{ + looptimerflag = true; +} + int main() { pc.baud(115200); - timer.attach(read,0.05); - timer.attach(viewer,0.05); -//timer.attach(scope,0.05); + timer.attach(setlooptimerflag,TSAMP); + //timer.attach(scope,0.05); while(1) { + while(!looptimerflag) + looptimerflag = false; + read(); y = filter(emg_value); - } + viewer(); + } } \ No newline at end of file