Alan Simms / Mbed 2 deprecated threeAxisTable

Dependencies:   mbed threeAxis mbed-rtos 4DGL-uLCD-SE

Revision:
14:d6c8724a69e8
Parent:
13:8231d6cce099
Child:
15:dee1c2f0e82f
--- a/main.cpp	Wed Dec 15 01:18:03 2021 +0000
+++ b/main.cpp	Wed Dec 15 02:10:57 2021 +0000
@@ -35,7 +35,7 @@
 uLCD_4DGL uLCD(p9,p10,p11);
 DigitalOut actualLED(LED1);
 Mutex LCD;
-Mutex blue;
+bool buffering;
 /*
 volatile int currX;
 volatile int currY;
@@ -68,8 +68,7 @@
     }
 }
 
-void parseCoords(std::string coords){
-    
+void parseCoords(std::string coords){    
     
     int start = 0;
     int end = coords.find(',');
@@ -86,13 +85,19 @@
     start = end + 1;
     end = coords.length();
     float tempZ = atof(coords.substr(start, end-start).c_str());
-
-    table.goTo(tempX, tempY, tempZ);
+    
+    if(!buffering){
+        table.goTo(tempX, tempY, tempZ);
+    }
+    else{
+        table.addToBuffer(tempX, tempY, tempZ);
+    }
     
 }
 
 void bluetooth_thread(){
-     
+    
+    
     //char bnum=0;
     while(1) {
         std::string coords = "";
@@ -100,36 +105,54 @@
         
         if (bluetooth.readable()){
             while (bluetooth.readable()){
+                
                 char temp = bluetooth.getc();
+                
                 if (temp == 'z'){
                     table.setZero();
                 }
+                else if(temp == 'b'){
+                    buffering = !buffering;
+                }
                 
-                else{
                     coords += temp;
-                }
             }
+        
             //Thread::wait(1000);
-            if (coords.find('z') == -1){
-                LCD.lock();
-                uLCD.printf("\n");
-                uLCD.printf(coords.c_str());
-                LCD.unlock();
-                parseCoords(coords);
+        LCD.lock();
+        uLCD.printf("\n");
+        if ((coords.find('z') == -1) && (coords.find('b') == -1)){                
+             uLCD.printf(coords.c_str());
+             LCD.unlock();
+             parseCoords(coords);
+                
+        }
+        else{
                 
-            }
-            else{
-                LCD.lock();
-                uLCD.printf("\n");
-                uLCD.printf("Zeroed!");
-                LCD.unlock();
-            }
+             if (coords.find('z') != -1){
+                 uLCD.printf("Zeroed!");
+                 LCD.unlock();
+             }
+             else if (coords.find('b') != -1){
+                 if (buffering){
+                     uLCD.printf("Now buffering!");
+                     LCD.unlock();
+                 }
+                 else if (!buffering){
+                     uLCD.printf("Time to run buffer!");
+                     LCD.unlock();
+                     table.runBuffer();
+                 }
+             }
         }
+    }
         
         
-    }
 }
 
+}
+
+
 int main() {
     //Y axis direction inverted from others to get behavior that makes me happy (rewards = negative, forward = positive)
     table.invertY();