Executes commands received via xbee.

Dependencies:   m3pi mbed

Files at this revision

API Documentation at this revision

Comitter:
bc6599
Date:
Tue Apr 21 15:48:31 2015 +0000
Parent:
0:98be52da5242
Child:
2:ce95322fe535
Commit message:
Added capacity for storing previous command

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Apr 19 16:01:27 2015 +0000
+++ b/main.cpp	Tue Apr 21 15:48:31 2015 +0000
@@ -7,28 +7,30 @@
 void execute();
 void set_command();
 
+//once we're finished, these can go in a separate header file.
 const char LEFT = 'A';
 const char RIGHT = 'B';
 const char STOP = 'D';
 const char FORWARD = 'E';
 const char BACKWARD = 'F';
+const float EX_TIME = 1.0;
 
 char command;
+char prev_command; //in case we need a command history
 float speed;
 
 int main() {
-    
+    prev_command = STOP;
     command = STOP;
     speed = 0.3;
-    m3pi.locate(0,1);
-    m3pi.printf("Hola");
+    m3pi.cls();
     
     while (1) {
-        set_command();
+        //set_command();
         m3pi.locate(0,1);
-        m3pi.printf("%c",command);
-        execute();
-        //wait(1);
+        m3pi.printf("%f", m3pi.battery());
+        //m3pi.printf("%c",command);
+        //execute();
     }
 }
 
@@ -49,7 +51,8 @@
 
 void set_command() {
     if (xbee.readable()) {
+        prev_command = command;
         command = xbee.getc();
-        wait(1);
+        wait(EX_TIME);
     }
 }
\ No newline at end of file