emg

Dependencies:   HIDScope MODSERIAL mbed-dsp mbed TouchButton

Fork of test by BMT M9 Groep01

Files at this revision

API Documentation at this revision

Comitter:
s1340735
Date:
Tue Oct 28 11:11:56 2014 +0000
Parent:
34:514440ddca9a
Child:
36:ccc901c169b7
Commit message:
while loop er uit gehaald

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 28 10:46:48 2014 +0000
+++ b/main.cpp	Tue Oct 28 11:11:56 2014 +0000
@@ -169,199 +169,195 @@
 
     TouchButton TButton;
 
-    int key=0;
+    int key;
 
     drempelwaardeT=0;
     drempelwaardeB1=0;
     drempelwaardeB2=0;
     drempelwaardeB3=0;
-    
+
     key = TButton.PresedButton();
 
     pc.printf("key 1 calibratie triceps/n");
     pc.printf("key 2 caliratie biceps/n");
     pc.printf("key 3 START/n");
 
-    wait(10);
+    if (key==0) {
+        myled1 = 1;
+        myled2 = 1;
+        myled3 = 1;
 
-    while(true) {
-        if (key==0) {
-            myled1 = 1;
-            myled2 = 1;
-            myled3 = 1;
+        pc.printf("calibratie tricep aan\n");
+        Calibratie_Triceps();
+        drempelwaardeT=MOVAVG_T-1;
+        pc.printf("drempelwaarde triceps is %f\r\n", drempelwaardeT);
+        pc.printf("calibratie tricep klaar\n");
+        wait(5);
+    }
+
+    if (key==1) {
+        myled1 = 1;
+        myled2 = 1;
+        myled3 = 0;
+        wait(0.1);
+
+        pc.printf("calibratie bicep snelheid 1 aan\n");
+        Calibratie_Biceps();
+        drempelwaardeB1=MOVAVG_B-1;
+        pc.printf("drempelwaarde snelheid 1 is %f\r\n", drempelwaardeB1);
+        wait(5);
 
-            pc.printf("calibratie tricep aan\n");
-            Calibratie_Triceps();
-            drempelwaardeT=MOVAVG_T-1;
-            pc.printf("drempelwaarde triceps is %f\r\n", drempelwaardeT);
-            wait(5);
+        pc.printf("calibratie bicep snelheid 2 aan\n");
+        Calibratie_Biceps();
+        drempelwaardeB2=MOVAVG_B-1;
+        pc.printf("drempelwaarde snelheid 2 is %f\r\n", drempelwaardeB2);
+        wait(5);
+
+        pc.printf("calibratie bicep snelheid 2 aan\n");
+        Calibratie_Biceps();
+        drempelwaardeB2=MOVAVG_B-1;
+        pc.printf("drempelwaarde snelheid 3 is %f\r\n", drempelwaardeB3);
+
+        pc.printf("caliratie biceps is klaar/n");
 
-            pc.printf("calibratie tricep klaar\n");
+        wait(5);
+    }
 
-        } else if (key==1) {
+    if (key==2) {
+        if (drempelwaardeT==0) {
+            pc.printf("voer calibratie triceps uit");
+        } else if (drempelwaardeB1==0) {
+            pc.printf("voer calibratie biceps uit");
+        } else if (drempelwaardeB2==0) {
+            pc.printf("voer calibratie biceps uit");
+        } else if (drempelwaardeB3==0) {
+            pc.printf("voer calibratie biceps uit");
+        } else {
             myled1 = 1;
-            myled2 = 1;
-            myled3 = 0;
+            myled2 = 0;
+            myled3 = 1;
             wait(0.1);
 
-            pc.printf("calibratie bicep snelheid 1 aan\n");
-            Calibratie_Biceps();
-            drempelwaardeB1=MOVAVG_B-1;
-            pc.printf("drempelwaarde snelheid 1 is %f\r\n", drempelwaardeB1);
-            wait(5);
+            pc.printf("eerst positie dan snelheid aangeven/n");
+
+            //bepaling van positie met triceps 1
+            Ticker log_timerT1;
+
+            arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
+            arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
+            arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
 
-            pc.printf("calibratie bicep snelheid 2 aan\n");
-            Calibratie_Biceps();
-            drempelwaardeB2=MOVAVG_B-1;
-            pc.printf("drempelwaarde snelheid 2 is %f\r\n", drempelwaardeB2);
-            wait(5);
+            log_timerT1.attach(Triceps, 0.005);
+            wait(10);
+            log_timerT1.detach();
+
+            MOVAVG_T=MOVAVG_Positie1;
+
+            // positie van batje met behulp van Triceps
 
-            pc.printf("calibratie bicep snelheid 2 aan\n");
-            Calibratie_Biceps();
-            drempelwaardeB2=MOVAVG_B-1;
-            pc.printf("drempelwaarde snelheid 3 is %f\r\n", drempelwaardeB3);
+            if (MOVAVG_Positie1>= drempelwaardeT) {
+                yT1=1;
+            } else {
+                yT1=0;
+            }
+
+            pc.printf("Triceps eerste meting is klaar.\n");
             wait(5);
 
-            pc.printf("caliratie biceps is klaar/n");
+            //bepaling van positie met tricep 2
+            Ticker log_timerT2;
 
-        } else if (key==2) {
-            if (drempelwaardeT==0) {
-                pc.printf("voer calibratie triceps uit");
-            } else if (drempelwaardeB1==0) {
-                pc.printf("voer calibratie biceps uit");
-            } else if (drempelwaardeB2==0) {
-                pc.printf("voer calibratie biceps uit");
-            } else if (drempelwaardeB3==0) {
-                pc.printf("voer calibratie biceps uit");
-            } else {
-                myled1 = 1;
-                myled2 = 0;
-                myled3 = 1;
-                wait(0.1);
+            arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
+            arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
+            arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
+
+            log_timerT2.attach(Triceps, 0.005);
+            wait(5);
+            log_timerT2.detach();
+
+            MOVAVG_T=MOVAVG_Positie2;
 
-                pc.printf("eerst positie dan snelheid aangeven/n");
+            if (MOVAVG_Positie2 >= drempelwaardeT) {
+                yT2=1;
+            } else {
+                yT2=0;
+            }
 
-                //bepaling van positie met triceps 1
-                Ticker log_timerT1;
-
-                arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
-                arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
-                arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
+            pc.printf("Triceps tweede meting is klaar.\n");
 
-                log_timerT1.attach(Triceps, 0.005);
-                wait(10);
-                log_timerT1.detach();
+            //*** INPUT MOTOR 2 ***
+            positie=yT1+yT2;
 
-                MOVAVG_T=MOVAVG_Positie1;
-
-                // positie van batje met behulp van Triceps
-
-                if (MOVAVG_Positie1>= drempelwaardeT) {
-                    yT1=1;
+            //controle positie op scherm
+            if (positie==0) {
+                pc.printf("Motor 2 blijft op stand 1\n");
+            } else {
+                if (positie==1) {
+                    pc.printf("Motor 2 gaat naar stand 2\n");
                 } else {
-                    yT1=0;
-                }
-
-                pc.printf("Triceps eerste meting is klaar.\n");
-                wait(5);
-
-                //bepaling van positie met tricep 2
-                Ticker log_timerT2;
-
-                arm_biquad_cascade_df1_init_f32(&notchT,1,notch_const,notch_states);
-                arm_biquad_cascade_df1_init_f32(&lowpassT,1,lowpass_const,lowpass_states);
-                arm_biquad_cascade_df1_init_f32(&highpassT,1,highpass_const,highpass_states);
-
-                log_timerT2.attach(Triceps, 0.005);
-                wait(5);
-                log_timerT2.detach();
-
-                MOVAVG_T=MOVAVG_Positie2;
-
-                if (MOVAVG_Positie2 >= drempelwaardeT) {
-                    yT2=1;
-                } else {
-                    yT2=0;
-                }
-
-                pc.printf("Triceps tweede meting is klaar.\n");
-
-                //*** INPUT MOTOR 2 ***
-                positie=yT1+yT2;
-
-                //controle positie op scherm
-                if (positie==0) {
-                    pc.printf("Motor 2 blijft op stand 1\n");
-                } else {
-                    if (positie==1) {
-                        pc.printf("Motor 2 gaat naar stand 2\n");
-                    } else {
-                        if (positie==2) {
-                            pc.printf("Motor 2 gaat naar stand 3\n");
-                        }
+                    if (positie==2) {
+                        pc.printf("Motor 2 gaat naar stand 3\n");
                     }
                 }
+            }
 
-                wait(5);
-
-                Ticker log_timerB;
+            wait(5);
 
-                arm_biquad_cascade_df1_init_f32(&notchB,1,notch_const,notch_states);
-                arm_biquad_cascade_df1_init_f32(&lowpassB,1,lowpass_const,lowpass_states);
-                arm_biquad_cascade_df1_init_f32(&highpassB,1,highpass_const,highpass_states);
+            Ticker log_timerB;
 
-                log_timerB.attach(Biceps,0.005);
-                wait(5);
-                log_timerB.detach();
+            arm_biquad_cascade_df1_init_f32(&notchB,1,notch_const,notch_states);
+            arm_biquad_cascade_df1_init_f32(&lowpassB,1,lowpass_const,lowpass_states);
+            arm_biquad_cascade_df1_init_f32(&highpassB,1,highpass_const,highpass_states);
 
-                //bepaling van snelheidsstand met biceps
+            log_timerB.attach(Biceps,0.005);
+            wait(5);
+            log_timerB.detach();
+
+            //bepaling van snelheidsstand met biceps
 
-                if (MOVAVG_B >= drempelwaardeB1) {
-                    yB1=1;
-                    if (MOVAVG_B >= drempelwaardeB2) {
-                        yB2=1;
-                        if (MOVAVG_B >= drempelwaardeB3) {
-                            yB3=1;
-                        } else {
-                            yB3=0;
-                        }
+            if (MOVAVG_B >= drempelwaardeB1) {
+                yB1=1;
+                if (MOVAVG_B >= drempelwaardeB2) {
+                    yB2=1;
+                    if (MOVAVG_B >= drempelwaardeB3) {
+                        yB3=1;
                     } else {
-                        yB2=0;
+                        yB3=0;
                     }
                 } else {
-                    yB1=0;
+                    yB2=0;
                 }
+            } else {
+                yB1=0;
+            }
 
-                //*** INPUT MOTOR 1 ***
-                snelheidsstand=yB1+yB2+yB3;
+            //*** INPUT MOTOR 1 ***
+            snelheidsstand=yB1+yB2+yB3;
 
-                //controle snelheidsstand op scherm
-                if (snelheidsstand==0) {
-                    pc.printf("Motor 1 beweegt niet\n");
+            //controle snelheidsstand op scherm
+            if (snelheidsstand==0) {
+                pc.printf("Motor 1 beweegt niet\n");
+            } else {
+                if (snelheidsstand==1) {
+                    pc.printf("Motor 1 beweegt met snelheid 1\n");
                 } else {
-                    if (snelheidsstand==1) {
-                        pc.printf("Motor 1 beweegt met snelheid 1\n");
+                    if (snelheidsstand==2) {
+                        pc.printf("Motor 1 beweegt met snelheid 2\n");
                     } else {
-                        if (snelheidsstand==2) {
-                            pc.printf("Motor 1 beweegt met snelheid 2\n");
-                        } else {
-                            if (snelheidsstand==3) {
-                                pc.printf("Motor 1 beweegt met snelheid 3\n");
-                            }
+                        if (snelheidsstand==3) {
+                            pc.printf("Motor 1 beweegt met snelheid 3\n");
                         }
                     }
                 }
             }
-        } else if(key==3) {
+        }
+        if(key==3) {
             myled1 = 0;
             myled2 = 1;
             myled3 = 1;
             wait(0.1);
 
             pc.printf("onbekend\n");
-
-        } else {
-            pc.printf("voer eerst een calibratie uit\n");
         }
     }
-}
+}
\ No newline at end of file