Finished!

Dependencies:   m3pi_ng mbed

Fork of BlueToothStuff by der Roboter

Revision:
2:cc7b01c5a9b0
Parent:
1:6402638c6f6d
Child:
3:bf9a0cd9750c
--- a/main.cpp	Thu May 22 14:43:25 2014 +0000
+++ b/main.cpp	Tue May 27 12:49:21 2014 +0000
@@ -36,9 +36,9 @@
    wait(0.3);
    
    thinggy.locate(0,0);
-   thinggy.printf("%s","btTest");
+   thinggy.printf("%s","Tell Me");
    thinggy.locate(0,1);
-   thinggy.printf("%s","PBonLNK");
+   thinggy.printf("%s","  Why  ");
 
    // wait for the user to push P21, should be pressed when the bt link is established (green led "link")
    while(m3pi_pb) {
@@ -49,8 +49,8 @@
    int iline=1;
    char arr_read[30]; // this should be long enough to store any reply coming in over bt.
    int  chars_read;   // number of chars read in a bt reply
-   
-   while (true) {
+   bool go = true;
+   while (go) {
        // this writes "Line 001\n" to "Line 005\n" and then "end\n" to the btbee
        if ( btbee.writeable() ) {
            if (iline==6) {
@@ -60,23 +60,56 @@
            else {
                if (iline <6){
                btbee.printf("Line %0.3d \n",iline);
-               m3pi_led[0]=0;
                thinggy.locate(0,0);
                thinggy.printf("Sent %0.3d",iline);
                iline++;
                }
            }//else
        }//if_write
-
+       go = false;
+    } // while_true
+    
+    go = true;
+    
+    
+    /*
+    while(go){
+       // wait for an input
+      while ( !btbee.readable() ) {
+           wait(0.01);
+           thinggy.locate(0,0);
+           thinggy.printf("I'm waiting");
+       }//while_notReadable
+    */  
        // check for answers after each write /not write
        while ( btbee.readable() ) {
-           m3pi_led[7]=1;
            btbee.read_all(arr_read, 30, &chars_read );
-           m3pi_led[6]=1;
-           thinggy.locate(0,1);
-           thinggy.print(arr_read,chars_read);
-           m3pi_led[5]=1;
+           thinggy.locate(0,0);
+           thinggy.cls();
+           thinggy.printf("IGotMsg!");
+           if (arr_read[0] == 'l'){
+               thinggy.locate(0,1);
+               thinggy.cls();
+               thinggy.printf("TurningL");
+               // add code to turn left
+               }
+           else if (arr_read[0] == 'r'){
+               thinggy.locate(0,1);
+               thinggy.cls();
+               thinggy.printf("TurningR");
+               // add code to turn right
+               }
+           else if (arr_read[0] == 'f'){
+               thinggy.locate(0,1);
+               thinggy.cls();
+               thinggy.printf("GoingFwd");
+               // add code to go forward
+               }
+           
+           
+           //thinggy.print(arr_read,chars_read);
        }//while_readable
+       
        wait(0.1);
    }//while_true
     
@@ -154,7 +187,3 @@
     returned = (sensor[1] + sensor[2] + sensor[3])/3;
     }
 */
-}
- 
- 
- 
\ No newline at end of file