State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Revision:
28:25917b26022c
Parent:
26:a8f4a117cc0d
Child:
29:77fee8a01529
--- a/main.cpp	Thu Nov 01 10:55:11 2018 +0000
+++ b/main.cpp	Thu Nov 01 12:31:39 2018 +0000
@@ -91,7 +91,8 @@
         last_state = current_state;
         // State just changed to this one.
 
-        led_green = 0;
+        led_green = 1;
+        led_blue = 1;
         screen.clear_display();
         screen.display_state_name("Motor calibration");
         
@@ -107,15 +108,22 @@
         main_is_calibrated = calibrate_motor(main_motor, main_last_angle, main_iterations_not_moving);
         if (main_is_calibrated) {
             main_motor.define_current_angle_as_x_radians(0.785398); // 45 degrees.
+            led_green = 0;
         }
     }
     if (!sec_is_calibrated) {
         sec_is_calibrated = calibrate_motor(sec_motor, sec_last_angle, sec_iterations_not_moving);
         if (sec_is_calibrated) {
             sec_motor.define_current_angle_as_x_radians(-0.733038); // -42 degrees.
+            led_blue = 0;
         }
     }
     
+    screen.get_screen_handle()->setTextCursor(0, 8);
+    screen.get_screen_handle()->printf("M: %i    \n", main_iterations_not_moving);
+    screen.get_screen_handle()->printf("S: %i    \n", sec_iterations_not_moving);
+    screen.display();
+    
     if (main_is_calibrated && sec_is_calibrated) {
         current_state = homing;
     }
@@ -355,13 +363,6 @@
     while (true) {
         main_loop();
         
-        // Button debugging.
-        if (ud_button.has_just_been_pressed() || lr_button.has_just_been_pressed() || p_button.has_just_been_pressed()) {
-            led_blue = 0;
-        } else {
-            led_blue = 1;
-        }
-        
         wait(main_loop_wait_time);
     }
 }
\ No newline at end of file