- This code combines steering and driving in one ticker - Fault check is in a ticker instead of while loop

Dependencies:   mbed MMA8451Q

Revision:
3:25c6bf0abc00
diff -r c857935f928e -r 25c6bf0abc00 bluetooth.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetooth.h	Mon Oct 25 01:39:55 2021 +0000
@@ -0,0 +1,38 @@
+#define BLUETOOTHBAUDRATE 115200 //Communication rate of the micro-controller
+ //to the Bluetooth module
+#define SERIALTXPORT PTE0 //Tx Pin (Sends information to serial device)
+#define SERIALRXPORT PTE1 //Rx Pin (Receives information from serial
+Serial bt(SERIALTXPORT, SERIALRXPORT); //(TX, RX) Serial declaration for new serial
+
+char newInputChar;
+int newInputInt;
+volatile bool newData = false;
+
+void btReceive() { //comment this out if it's fucked
+
+ static char buffer[6];
+ static int serialCount = 0;
+ 
+{
+        char byteIn = bt.getc();
+      //  bt.printf("Got %c",byteIn);
+        if (byteIn == 'n') {
+            buffer[serialCount] = 0;
+            //bt.printf("Got endl %c",byteIn);
+            int speed;
+            char type;
+            if (sscanf(buffer,"%c%i",&type,&speed) == 2) {
+                newInputChar = type;
+               // bt.printf("char: %c", type);
+                newInputInt = speed;
+               // bt.printf("speed: %i", speed);
+                newData = true;
+                }
+            serialCount = 0;
+            } else {
+                buffer[serialCount] = byteIn;
+                if (serialCount < 6)
+                serialCount++;
+                }
+        }
+    }
\ No newline at end of file