
- This code combines steering and driving in one ticker - Fault check is in a ticker instead of while loop
bluetooth.h
- Committer:
- aalawfi
- Date:
- 2021-10-25
- Revision:
- 9:5f032ca6c9b5
- Parent:
- 3:25c6bf0abc00
File content as of revision 9:5f032ca6c9b5:
#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++; } } }