Source code for Active Aerodynamics and Drag Reduction System

Dependencies:   mbed Servo mbed-rtos LSM9DS1_Library_cal MPL3115A2

Files at this revision

API Documentation at this revision

Comitter:
abir77935
Date:
Tue Apr 21 06:55:43 2020 +0000
Parent:
0:04fef978a0ab
Child:
2:426f26e9801d
Commit message:
added Uart code for Bluetooth interactability

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Apr 13 14:04:34 2020 +0000
+++ b/main.cpp	Tue Apr 21 06:55:43 2020 +0000
@@ -20,6 +20,10 @@
 
 // VARIABLE DECLARATIONS 
 volatile char bluetoothRead = 0;
+volatile float xAccel = 0;
+volatile float yAccel = 0;
+volatile float zAccel = 0;
+volatile float tuning = 1;
 
 
 // FUNCTION DECLARATIONS
@@ -75,6 +79,10 @@
     pc.printf("mag:   %9f %9f %9f in gauss\n\r", IMU.calcMag(IMU.mx), IMU.calcMag(IMU.my), IMU.calcMag(IMU.mz));
     printAttitude(IMU.calcAccel(IMU.ax), IMU.calcAccel(IMU.ay), IMU.calcAccel(IMU.az), IMU.calcMag(IMU.mx),
                   IMU.calcMag(IMU.my), IMU.calcMag(IMU.mz));
+                  
+    zAccel = IMU.calcAccel(IMU.az));//setting global variable for storage of z-Axis acceleration
+    yAccel = IMU.calcAccel(IMU.ay));
+    xAccel = IMU.calcAccel(IMU.ax));
 } 
 
 
@@ -86,6 +94,24 @@
     }
 }
 
+//Prints the acceraltion data to the bluetooth UART window
+void blue_rec()
+{    
+    while(1){
+        dev.putc(zAccel);
+        Thread::wait(1000);
+    }
+}
+
+/*
+//take in data from UART window on bluetooth to adjust tuning variables
+void blue_tuning()
+{
+    while(dev.readable()) {
+        tuning = dev.getc();
+    }
+}
+*/
 
 int main() {
     // initialise IMU
@@ -99,6 +125,9 @@
     // Start threads
     thread1.start(thread1Name);
     
+    blue.baud(9600); //set baud rate for UART window
+    blue.attach(&blue_rec, Serial::RxIrq);
+    
     while(1) {
         // things
         Thread::wait(1000);