Final Project files for mBed development.

Dependencies:   m3pi mbed

Files at this revision

API Documentation at this revision

Comitter:
alecguertin
Date:
Sat Dec 13 03:34:04 2014 +0000
Parent:
36:f25de790ea0b
Parent:
37:1d51cf101b03
Child:
39:cc8691700d2a
Commit message:
merged

Changed in this revision

--- a/main.c	Fri Dec 12 08:46:22 2014 +0000
+++ b/main.c	Sat Dec 13 03:34:04 2014 +0000
@@ -93,9 +93,9 @@
         oled_1 = 1;
         while(1);
     }
-    right(180);
+    right(183);
     timerWait(.2);
-    int wiggle_count = 0;
+    /*int wiggle_count = 0;
     
     for(    ; fabs(pos = pi.line_position()) > CLOSE_ENOUGH 
             && wiggle_count < WIGGLE_MAX; wiggle_count++) {
@@ -103,10 +103,11 @@
         pi.cls();
         pi.locate(0,0);
         pi.printf("O: %f", pos);
-    }
-    pi.stop();    
+    }*/
+    pi.stop();
     timerWait(0.2);
     backward(400);
+    //while(1);
     
     // ---------------------------------------------------------
     // DONE calibrating. Begin reading in coordinate
@@ -158,6 +159,7 @@
             pi.cls();
             pi.locate(0,0);
             pi.printf("%s", instbuf+1);
+            oled_3 = 0;
             while(1);
         }
         
@@ -211,6 +213,7 @@
         pi.cls();
         pi.locate(0,0);
         pi.printf("a:%f", delta_a);
+        oled_3 = 0;
         left(delta_a);
 
         /* Put pen into position. */
@@ -290,9 +293,9 @@
     pi.right_motor(DRIVE_SPEED);
     ms = t.read_ms();
     while(ms < amt) {
-        if (ms-last_ms > 1000) {
+        if (ms-last_ms > 500) {
             t.stop();
-            right(3);
+            right(1.5);
             last_ms = ms;
             t.start();
             pi.left_motor(DRIVE_SPEED+.002);
@@ -314,15 +317,16 @@
 
 void right(float deg)
 {
+    deg += 2;
     if(deg < 0) {
         return left(-1*deg);
     }
-    deg = deg+1.5;
+    deg = deg;
     Timer t;
-    float amt = ((float)(deg/360)*TIME_FACT);
+    float amt = ((((float)deg)/360)*TIME_FACT*1000);
     t.start();
     pi.right(TURN_SPEED);
-    while(t.read_ms() < amt);
+    while(t.read_us() < amt);
     pi.stop();
 }
 
@@ -338,10 +342,10 @@
     if(deg < 0) {
         return right(-1*deg);
     }
-    deg = deg + 1.5;
+    float amt = (((float)deg)/360)*TIME_FACT*1000;
     Timer t;
     pi.left(TURN_SPEED);
     t.start();
-    while(t.read_ms() < ((float)(deg/360)*TIME_FACT));
+    while(t.read_us() < amt);
     pi.stop();
 }
\ No newline at end of file
--- a/main.h	Fri Dec 12 08:46:22 2014 +0000
+++ b/main.h	Sat Dec 13 03:34:04 2014 +0000
@@ -22,7 +22,7 @@
 #define TIME_FACT 1780      /**< Multiplier for forward() and backward() */
 #define CAL_SPEED .25       /**< Drive speed during calibration */
 #define CLOSE_ENOUGH .0008  /**< Threshold for calibration line centering */
-#define WIGGLE_MAX 15       /**< Max 'wiggles' during calibration */
+#define WIGGLE_MAX 30       /**< Max 'wiggles' during calibration */
 
 /** @brief Move the robot from its current position to (x,y) */
 void move(int x, int y, int draw);