Testing

Dependencies:   mbed mbed-rtos 4DGL-uLCD-SE Motor BNO055 SDFileSystem HC_SR04_Ultrasonic_Library

Files at this revision

API Documentation at this revision

Comitter:
elisham11
Date:
Thu Nov 28 02:02:03 2019 +0000
Commit message:
Testing for documentation

Changed in this revision

4DGL-uLCD-SE.lib Show annotated file Show diff for this revision Revisions of this file
BNO055.lib Show annotated file Show diff for this revision Revisions of this file
HC_SR04_Ultrasonic_Library.lib Show annotated file Show diff for this revision Revisions of this file
Motor.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/4DGL-uLCD-SE.lib	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/4180_1/code/4DGL-uLCD-SE/#e39a44de229a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BNO055.lib	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/vargham/code/BNO055/#f5880506defe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HC_SR04_Ultrasonic_Library.lib	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ejteb/code/HC_SR04_Ultrasonic_Library/#e0f9c9fb4cf3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor.lib	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/Motor/#f265e441bcd9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/neilt6/code/SDFileSystem/#e4d2567200db
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,234 @@
+#include "mbed.h"
+#include "rtos.h" //mbed's thread and mutex are included here
+#include <string>
+#include "SDFileSystem.h"
+#include "Motor.h"
+#include "BNO055.h"
+#include "ultrasonic.h"
+
+//Timer
+Timer t; //t.start(), t.stop(), t.read()
+
+//Semaphore s(1);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+//H-bridge
+Motor m_left(p21, p15, p16); // pwm,fwd,rev pwmA
+Motor m_right(p22, p19, p20); // pwm,fwd,rev 
+
+//SDcard
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+
+//Sonar 1 & 2
+//void newdist();
+//ultrasonic mu1(p29, p30, .07, 1, &newdist); 
+//ultrasonic mu2(p11, p12, .07, 1, &newdist);
+
+//Bluetooth
+// don't forgot to use mutex and volatile
+//RawSerial  pc(USBTX, USBRX);
+/*
+1 for imu rotation
+2 for reverse
+3 for forward
+4 for left
+5 for right
+*/
+Serial pc(USBTX, USBRX);
+RawSerial  Bluetooth(p28,p27);
+
+//Global variables for bluetooth control
+bool sonarOn = false; //Indicates when sonar is taking measurements
+bool running = true; //Keeps main while loop going
+
+
+   
+//Code for interrupt routine for Bluetooth input
+enum statetype {start = 0, got_exclm, got_B, got_one, got_two, got_three, got_five, got_six, got_seven, got_eight, got_11, got_21, got_31, got_51, got_61, got_71, got_81};
+statetype state = start;
+//Interrupt routine to parse message with one new character per serial RX interrupt
+void parse_message()
+{
+    led1 = !led1;
+    switch (state)
+    {
+        case start:
+            if (Bluetooth.getc()=='!')
+            {
+                led2 = 1;
+                state = got_exclm;
+            }
+            else state = start;
+            break;
+        case got_exclm:
+            
+            if (Bluetooth.getc() == 'B')
+            {
+                led3 = 1;
+                state = got_B;
+            }
+            else state = start;
+            break;
+        case got_B:
+        {
+            char recv = Bluetooth.getc();
+            if (recv == '1') state = got_one;
+            else if (recv == '2') state = got_two;
+            else if (recv == '3') state = got_three;
+            else if (recv == '5') state = got_five;
+            else if (recv == '6') state = got_six;
+            else if (recv == '7') state = got_seven;
+            else if (recv == '8') state = got_eight;
+            else state = start;
+        }
+        break;
+        case got_one:
+            if (Bluetooth.getc() == '1')
+            {
+                
+            }
+            else state = start;
+            break;
+        case got_two: //Stop everything
+            if (Bluetooth.getc() == '1')
+            {
+                //Make sure motors are stopped
+                m_left.speed(0.0); 
+                m_right.speed(0.0);
+                sonarOn = false;
+                running = false;
+            }
+            else state = start;
+            break;  
+        case got_three: //currently unimplemented
+            if (Bluetooth.getc() == '1')
+            {
+                
+            }
+            else state = start;
+            break;
+        case got_five: //up arrow pressed
+        {
+            char recv = Bluetooth.getc();
+            if (recv == '1') //Button pressed or held
+            {
+                sonarOn = true;
+                m_left.speed(0.3);
+                m_right.speed(0.3);
+                led3 = 1;
+            }
+            else if (recv == '0') //Button released
+            {
+                sonarOn = false;
+                m_left.speed(0.0);
+                m_right.speed(0.0);
+                led4 = 1;
+            }
+            else state = start;
+        }
+            break;      
+        case got_six: //down arrow pressed
+        {
+            char recv = Bluetooth.getc();
+            if (recv == '1') //Button pressed or held
+            {
+                sonarOn = true;
+                m_left.speed(-0.3);
+                m_right.speed(-0.3);
+            }
+            else if (recv == '0')
+            {
+                sonarOn = false;
+                m_left.speed(0.0);
+                m_right.speed(0.0);
+            }
+            else state = start;
+        }
+            break;    
+        case got_seven: //turn left
+        {
+            char recv = Bluetooth.getc();
+            sonarOn = false;
+            if (recv == '1')
+            {
+                m_left.speed(-0.3);
+                m_right.speed(0.3);
+            }
+            else if (recv == '0')
+            {
+                m_left.speed(0.0);
+                m_right.speed(0.0);
+            }
+            else state = start;
+        }
+            break;  
+        case got_eight: //turn right
+        {
+            char recv = Bluetooth.getc();
+            sonarOn = false;
+            if (recv == '1')
+            {
+                m_left.speed(0.3);
+                m_right.speed(-0.3);
+            }
+            else if (recv == '0')
+            {
+                m_left.speed(0.0);
+                m_right.speed(0.0);
+            }
+            else state = start;
+        }
+            break;  
+
+        default:
+            Bluetooth.getc();
+            state = start;
+    }
+}
+
+
+//phototransistor and IC
+
+
+
+
+
+//Function to run in thread for speaker music    
+
+
+void newDist()
+{
+    
+}
+    
+
+
+int main() 
+{
+    
+    //Thread t1;
+    //Thread t2;
+    //Thread t3;
+    //t1.set_priority(osPriorityHigh);
+    //t2.set_priority(osPriorityLow);
+    //t3.set_priority(osPriorityRealtime);
+
+    
+    //Thread t4; 
+    //t4.start(parse_direction);
+    
+    //Attach Bluetooth interrupt routine
+    Bluetooth.attach(&parse_message,Serial::RxIrq);
+
+    while (1)
+    {
+        //printf("print\t");
+        Thread::wait(1000);
+    }
+    
+    
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 28 02:02:03 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0ab6a29f35bf
\ No newline at end of file