ECE3872 HW/SW Project Code

Dependencies:   mbed Servo mbed-rtos 4DGL-uLCD-SE PinDetect X_NUCLEO_53L0A1

Files at this revision

API Documentation at this revision

Comitter:
trmontgomery
Date:
Sat Apr 11 20:56:21 2020 +0000
Parent:
12:0528ef6978ec
Commit message:
re-added motor_ctl.h

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
motor_ctl.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sat Apr 11 19:34:47 2020 +0000
+++ b/main.cpp	Sat Apr 11 20:56:21 2020 +0000
@@ -32,6 +32,8 @@
         6. LED goes from green to red
         NOTE: ONLY exits to stop or erase state 
     */
+    
+    
 }
 void stop(){
     /* stop state:
@@ -71,6 +73,7 @@
 
 void state_machine_mgr(){
     char curr_state =  1;
+    char prev_state = 1;
     char key_input;
     X = 1;
     S = 0;
@@ -86,12 +89,14 @@
             if(key_input == '4') P=1;   //toggle play
             if(key_input == '5') E=1;   //toggle erase
         }
-        pc.printf("X: %d\n",X);
-        pc.printf("S: %d\n",S);
-        pc.printf("R: %d\n",R);
-        pc.printf("P: %d\n",P);
-        pc.printf("E: %d\n",E);
-        pc.printf("Current State %d\n",curr_state);
+        if (curr_state != prev_state){
+            pc.printf("X: %d\n",X);
+            pc.printf("S: %d\n",S);
+            pc.printf("R: %d\n",R);
+            pc.printf("P: %d\n",P);
+            pc.printf("E: %d\n",E);
+            pc.printf("Current State %d\n",curr_state);
+        }
         // Implementing state machine logical transitions based on what states can exit to other states
         if(X){
             if(E){
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/motor_ctl.h	Sat Apr 11 20:56:21 2020 +0000
@@ -0,0 +1,52 @@
+/*// Hello World to sweep a servo through its full range
+
+#include "mbed.h"
+#include "Servo.h"
+#include "rtos.h"
+
+Servo r_arm(p18);
+Servo l_arm(p19);
+//Servo r_leg(p20);
+//Servo l_leg(p21);
+
+Thread t_r_arm;
+Thread t_l_arm;
+//Thread t_r_leg;
+//Thread t_l_leg;
+
+DigitalOut led(LED4); 
+
+//left sensor move whole left side
+//right sensor moves whole right side //not gonna think about this right now. Dicuss ideas with team. 
+//and then the distance can just control the height
+//movement pattern can be random.. right now every other note recorded will be distributed to one side and the rest will go to the other
+
+
+float dists[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}; //should I lock this or just make new arrs?
+float r_dists[] = {1,3,5,7,9,11,13,15,17,19};
+float l_dists[] = {2,4,6,8,10,12,14,16,18,20};
+
+
+void r_dance() {    
+    r_arm = 0; 
+    for(int i = 0; i < 10; ++i) {
+        r_arm = r_dists[i]/20;
+        wait(0.2);
+    }
+}
+
+void l_dance() {    
+    l_arm = 0; 
+    for(int i = 0; i < 10; ++i) {
+        l_arm = l_dists[i]/20;
+        wait(0.2);
+    }
+}
+
+
+void motor_ctl(){
+    t_r_arm.start(r_dance);
+    t_l_arm.start(l_dance);
+}
+
+*/
\ No newline at end of file