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 12:47:57 2014 +0000
Parent:
35:e60f09b575d7
Child:
37:8b15c29445d3
Commit message:
andere loops

Changed in this revision

TouchButton.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/TouchButton.lib	Tue Oct 28 11:11:56 2014 +0000
+++ b/TouchButton.lib	Tue Oct 28 12:47:57 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/virajjayaweera/code/TouchButton/#2afd6e977c5b
+http://developer.mbed.org/teams/BMT-M9-Groep01/code/TouchButton/#e2599f77aa36
--- a/main.cpp	Tue Oct 28 11:11:56 2014 +0000
+++ b/main.cpp	Tue Oct 28 12:47:57 2014 +0000
@@ -17,15 +17,14 @@
 DigitalOut myled3(LED3);//blue
 
 /* FRDM-KL25Z built-in touch slider
-*************************
-*     *     *     *     *
-*  1  *  2  *  3  *  4  *
-*     *     *     *     *
-*************************
+*******************
+*     *     *     *
+*  1  *  2  *  3  *
+*     *     *     *
+*******************
 * key 1 will light Red LED                  -> CALIBRATIE TRICEPS
 * key 2 will light Green LED                -> CALIBRATIE BICEPS
 * key 3 will light Blue LED                 -> START
-* key 4 will light White LED (R+G+B)        -> ?ONBEKEND
 */
 
 //*** OBJECTS ***
@@ -167,23 +166,26 @@
 {
     pc.baud(115200);
 
-    TouchButton TButton;
-
-    int key;
-
     drempelwaardeT=0;
     drempelwaardeB1=0;
     drempelwaardeB2=0;
     drempelwaardeB3=0;
 
-    key = TButton.PresedButton();
+    TouchButton TButton;
+
+    int key=0;
+    key = TButton.PressedButton();
 
     pc.printf("key 1 calibratie triceps/n");
     pc.printf("key 2 caliratie biceps/n");
     pc.printf("key 3 START/n");
 
+    wait(3);
+
     if (key==0) {
-        myled1 = 1;
+
+        //rood
+        myled1 = 0;
         myled2 = 1;
         myled3 = 1;
 
@@ -191,173 +193,186 @@
         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 bicep snelheid 2 aan\n");
-        Calibratie_Biceps();
-        drempelwaardeB2=MOVAVG_B-1;
-        pc.printf("drempelwaarde snelheid 2 is %f\r\n", drempelwaardeB2);
+        pc.printf("calibratie tricep klaar, accord? -> key 4 \n");
         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);
+        if (key==3) {
+
+            pc.printf("key 2 caliratie biceps/n");
+            pc.printf("key 3 START/n");
+            wait(3);
+
+            if (key==1) {
 
-        pc.printf("caliratie biceps is klaar/n");
+                //green
+                myled1 = 1;
+                myled2 = 0;
+                myled3 = 1;
+                wait(0.1);
 
-        wait(5);
-    }
+                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);
 
-    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);
+                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("eerst positie dan snelheid aangeven/n");
+                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, accord? -> key 4/n");
 
-            //bepaling van positie met triceps 1
-            Ticker log_timerT1;
+                wait(5);
+
+                if (key==3) {
+
+                    pc.printf("key 2 caliratie biceps/n");
+                    pc.printf("key 3 START/n");
+                    wait(3);
 
-            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);
+                    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 {
 
-            log_timerT1.attach(Triceps, 0.005);
-            wait(10);
-            log_timerT1.detach();
+                            //blue
+                            myled1 = 1;
+                            myled2 = 1;
+                            myled3 = 0;
+                            wait(0.1);
 
-            MOVAVG_T=MOVAVG_Positie1;
-
-            // positie van batje met behulp van Triceps
+                            pc.printf("eerst positie dan snelheid aangeven/n");
 
-            if (MOVAVG_Positie1>= drempelwaardeT) {
-                yT1=1;
-            } else {
-                yT1=0;
-            }
+                            //bepaling van positie met triceps 1
+                            Ticker log_timerT1;
 
-            pc.printf("Triceps eerste meting is klaar.\n");
-            wait(5);
+                            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_timerT1.attach(Triceps, 0.005);
+                            wait(10);
+                            log_timerT1.detach();
 
-            //bepaling van positie met tricep 2
-            Ticker log_timerT2;
+                            MOVAVG_T=MOVAVG_Positie1;
+
+                            // positie van batje met behulp van Triceps
 
-            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);
+                            if (MOVAVG_Positie1>= drempelwaardeT) {
+                                yT1=1;
+                            } else {
+                                yT1=0;
+                            }
 
-            log_timerT2.attach(Triceps, 0.005);
-            wait(5);
-            log_timerT2.detach();
-
-            MOVAVG_T=MOVAVG_Positie2;
+                            pc.printf("Triceps eerste meting is klaar.\n");
+                            wait(5);
 
-            if (MOVAVG_Positie2 >= drempelwaardeT) {
-                yT2=1;
-            } else {
-                yT2=0;
-            }
+                            //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);
 
-            pc.printf("Triceps tweede meting is klaar.\n");
+                            log_timerT2.attach(Triceps, 0.005);
+                            wait(5);
+                            log_timerT2.detach();
+
+                            MOVAVG_T=MOVAVG_Positie2;
 
-            //*** INPUT MOTOR 2 ***
-            positie=yT1+yT2;
+                            if (MOVAVG_Positie2 >= drempelwaardeT) {
+                                yT2=1;
+                            } else {
+                                yT2=0;
+                            }
 
-            //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");
-                    }
-                }
-            }
+                            pc.printf("Triceps tweede meting is klaar.\n");
+
+                            //*** INPUT MOTOR 2 ***
+                            positie=yT1+yT2;
 
-            wait(5);
-
-            Ticker log_timerB;
+                            //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");
+                                    }
+                                }
+                            }
 
-            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);
+                            wait(5);
+
+                            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;
-                    }
-                } else {
-                    yB2=0;
-                }
-            } else {
-                yB1=0;
-            }
+                            if (MOVAVG_B >= drempelwaardeB1) {
+                                yB1=1;
+                                if (MOVAVG_B >= drempelwaardeB2) {
+                                    yB2=1;
+                                    if (MOVAVG_B >= drempelwaardeB3) {
+                                        yB3=1;
+                                    } else {
+                                        yB3=0;
+                                    }
+                                } else {
+                                    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");
-            } else {
-                if (snelheidsstand==1) {
-                    pc.printf("Motor 1 beweegt met snelheid 1\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");
+                            //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==2) {
+                                        pc.printf("Motor 1 beweegt met snelheid 2\n");
+                                    } else {
+                                        if (snelheidsstand==3) {
+                                            pc.printf("Motor 1 beweegt met snelheid 3\n");
+                                        }
+                                    }
+                                }
+                            }
                         }
                     }
                 }
             }
         }
-        if(key==3) {
-            myled1 = 0;
-            myled2 = 1;
-            myled3 = 1;
-            wait(0.1);
+    }
+}
 
-            pc.printf("onbekend\n");
-        }
-    }
-}
\ No newline at end of file
+
+