
first commit
bluetooth.h
- Committer:
- aalawfi
- Date:
- 2021-11-22
- Revision:
- 34:cb9a0cec2feb
- Parent:
- 3:25c6bf0abc00
File content as of revision 34:cb9a0cec2feb:
#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++; } } }