State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Revision:
33:543debddb3a9
Parent:
32:b63b5837bcb1
Child:
34:ae62ebf4d494
diff -r b63b5837bcb1 -r 543debddb3a9 main.cpp
--- a/main.cpp	Thu Nov 01 14:11:30 2018 +0000
+++ b/main.cpp	Thu Nov 01 14:39:55 2018 +0000
@@ -99,20 +99,20 @@
     }
     
     if (!main_is_calibrated) {
+        led_green = 1;
         main_is_calibrated = calibrate_motor(main_motor, main_last_angle, main_iterations_not_moving);
         if (main_is_calibrated) {
-            double calibration_angle = 0.785398; // 45 degrees.
-            main_motor.define_current_angle_as_x_radians(calibration_angle);
-            main_motor.set_target_angle(calibration_angle - 0.1); // Give the arm some breathing space.
+            main_motor.define_current_angle_as_x_radians(main_motor_calibration_angle);
+            //main_motor.set_target_angle(main_motor_calibration_angle - 0.2); // Give the arm some breathing space.
             led_green = 0;
         }
     }
     if (!sec_is_calibrated) {
+        led_blue = 1;
         sec_is_calibrated = calibrate_motor(sec_motor, sec_last_angle, sec_iterations_not_moving);
         if (sec_is_calibrated) {
-            double calibration_angle = -0.733038; // -42 degrees.
-            sec_motor.define_current_angle_as_x_radians(-0.733038); // -42 degrees.
-            main_motor.set_target_angle(calibration_angle + 0.1); // Give the arm some breathing space.
+            sec_motor.define_current_angle_as_x_radians(sec_motor_calibration_angle); // -42 degrees.
+            //main_motor.set_target_angle(sec_motor_calibration_angle + 0.2); // Give the arm some breathing space.
             led_blue = 0;
         }
     }
@@ -145,6 +145,11 @@
         
         main_motor.set_target_angle(main_home);
         sec_motor.set_target_angle(sec_home);
+        
+        screen.get_screen_handle()->setTextCursor(0, 8);
+        screen.get_screen_handle()->printf("Ma: %.6f    \n", main_home);
+        screen.get_screen_handle()->printf("Sa: %.6f    \n", sec_home);
+        screen.display();
     }
     
     if (ud_button.has_just_been_pressed()) {