Remco Dasselaar / Mbed 2 deprecated TotalControlEmg2

Dependencies:   HIDScope MODSERIAL QEI TextLCD mbed

Fork of TotalControlEmg2 by Remco Dasselaar

Revision:
49:b571c822c3f9
Parent:
48:07e3cf7dc819
Child:
50:16314b798754
diff -r 07e3cf7dc819 -r b571c822c3f9 main.cpp
--- a/main.cpp	Tue Oct 27 11:58:16 2015 +0000
+++ b/main.cpp	Tue Oct 27 12:01:44 2015 +0000
@@ -10,7 +10,6 @@
 //--------------------Classes------------------------
 InterruptIn btnSet(PTC6);           // Kalibration button
 InterruptIn emgSet(PTA4);           // EMG on/off button
-//DigitalOut ledR(LED_RED), LedB(LED3); // Leds on K64F
 MODSERIAL pc(USBTX, USBRX);         // Modserial voor Putty
 TextLCD lcd(PTC5, PTC7, PTC0, PTC9, PTC8, PTC1); // LCD screen on inner row of K64F, rs, e, d4-d7
 PwmOut servo(D3);                   // PwmOut servo
@@ -179,11 +178,6 @@
         pwmM2.write(0);                                 // Aim motor freeze
         aimState = OFF;                                 // next state
         }    
-    /*else if((modeR == 2 && R) && (modeL == 2 && L)) {             // modes are both 2
-        both = true;                                    // Return true
-        pwmM2.write(0);                                 // Aim motor freeze
-        aimState = OFF;                                 // next state
-        }*/ 
     else if((modeR == 2)) {                             // modeR ==2
         if(aimState != CCW){                            
             aimState = CCW;                             // Rotate CCW
@@ -213,7 +207,7 @@
     btnSet.mode(PullUp);                                // Button mode
     btnSet.rise(&btnSetAction);                         // Connect button to function
     emgSet.mode(PullUp);                                // Button mode
-    emgSet.rise(&emgOnOff);                         // Connect button to function      
+    emgSet.rise(&emgOnOff);                             // Connect button to function      
     tickerControl.attach(&setControlFlag,tControl);     // ticker control motor           
     EMGticker.attach(&setEmgFlag, t);                   // ticker EMG, 500H
     tickerLcd.attach(&setLcdFlag,tLcd);                 // ticker lcd   
@@ -234,13 +228,13 @@
                 printf("Position is kalibrating\r\n");  // terminal
                 PRINT("Wait a moment,   please");       // LCD                          
                 dirM2.write(0);                         // direction aim motor
-                pwmM2.write(0.2);                      // percentage motor power
-                bool calibrated = false;                //                       
+                pwmM2.write(0.2);                       // percentage motor power
+                bool calibrated = false;                                       
                 while(state==CALIBRATE_AIM){               
                     if(controlFlag){       
                         controlFlag = false;
                         if(!calibrated){                        // Not calibrated
-                            if((ksRight.read()>0.8)){               // Killswitch? 
+                            if((ksRight.read()>0.8)){           // Killswitch? 
                                 pwmM2.write(0);                 // Aim motor freeze
                                 enc2.reset();                   // Reset encoder 
                                 PRINT("Aim calibrated");        // LCD
@@ -248,10 +242,10 @@
                                 calibrated = true;                          
                                 pc.printf("Go to midi position\r\n");
                                 dirM2.write(1);                 // direction aim motor
-                                pwmM2.write(0.2);              // percentage motor power, turn it on                     
+                                pwmM2.write(0.2);               // percentage motor power, turn it on                     
                                 }
                             }                                    
-                        if(calibrated) {                                  // Calibrated                           
+                        if(calibrated) {                        // Calibrated                           
                             checkAim();                         // Check killswitches                                               
                             if(abs(enc2.getPulses()) > 600){    // rotate aim motor to midi position
                                 pwmM2.write(0);                 // Aim motor freeze
@@ -260,6 +254,7 @@
                             }     
                         }
                     }
+                lcd.cls();
                 break;
                 }            
             case CALIBRATE_BEAM: {