ECE 4180 - Final Project Team / Mbed 2 deprecated WalkieTalkie

Dependencies:   mbed 4DGL-uLCD-SE mbed-rtos nRF24L01P

Revision:
29:0c6f3c0c992a
Parent:
27:08d34e60b6d0
Child:
30:1c309c020125
--- a/main.cpp	Sun Apr 22 00:48:48 2018 +0000
+++ b/main.cpp	Mon Apr 23 15:03:21 2018 +0000
@@ -27,14 +27,14 @@
 Speaker spkr(p18);
 Microphone mic(p16);
 
-uLCD_4DGL uLCD(p27, p28, p30);                      // serial tx, serial rx, reset pin;
+//uLCD_4DGL uLCD(p27, p28, p30);                      // serial tx, serial rx, reset pin;
 
 nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10);    // mosi, miso, sck, csn, ce, irq
 CircularBuf<uint8_t> txbuff( FIFO_BUFFER_SCALE * DATA_PACKET_SIZE );
 CircularBuf<uint8_t> rxbuff( FIFO_BUFFER_SCALE * DATA_PACKET_SIZE );
 Ticker sampler; //10:41 am 4/20
 
-InterruptIn button(p18); //changed DitialIn to InterruptIn at 5:54 4/18/18
+InterruptIn button(p12); //changed DitialIn to InterruptIn at 5:54 4/18/18
 BusIn channel(p21, p22, p23, p24); // TODO: CHANGE THESE TO THE ACTUAL PINS NEEDED
 
 int rfFreq;
@@ -56,7 +56,7 @@
 // Sets the frequency of the RF device based on which swtiches are flipped
 // TODO: Make sure we don't have to restart the device or anything to change this
 void setRFFrequency() {
-    int channelNum = channel.read();
+    int channelNum = 0;//channel.read();
     
     // TODO: Don't force it to the default RF frequency
     channelNum = 2;
@@ -96,13 +96,13 @@
     }
     
     // TODO: This will have to be removed later on once we actually crank up the sample rate
-    pc.printf("Sampling....\n\r");
     myled3 = !myled3;
 }
 
 // Communicates to the other MBED using RF
 void commThread()
 {
+    pc.printf("Enter commThread\n\r");
     // We want this in it's own thread so we don't have to worry about the
     // timings screwing anything else up
     // It can't be in an interrupt because of that
@@ -147,7 +147,9 @@
 // Displays the current info to the LCD display
 void lcdThread()
 {
+    pc.printf("Enter lcdThread\n\r");
     while (1) {
+        /*
         uLCD.locate(64, 20);
         uLCD.printf("Frequency: %d MHz", rfFreq);
         uLCD.locate(64, 40);
@@ -166,7 +168,7 @@
                 uLCD.printf("Mode: Transmitting");
                 break;
         }
-        
+        */
         // Maybe add some graphics too idk
         Thread::wait(50);
     }
@@ -192,9 +194,31 @@
     
     mode = RECEIVE;
     
+    CircularBuf<int> temp(20);
+    int t[1];
+    for (int i = 0; i < 5; i++) {
+        t[0] = i;
+        pc.printf("%d.", temp.push(&t[0], 1));
+    }
+    pc.printf("\n\rBuff size %d\n\r", temp.size());
+    
+    for (int i = 0; i < 20; i++) {
+        pc.printf("%d ", temp._data[i]);
+    }
+    pc.printf("\n\r%d %d\n\r", temp._head, temp._tail);
+    
+    for (int i = 0; i < 5; i++) {
+        t[0] = 0;
+        pc.printf("%d.", temp.pop(&t[0], 1));
+        pc.printf("%d ",  t);
+        pc.printf("\n\r%d %d\n\r", temp._head, temp._tail);
+    }
+    pc.printf("\n\rBuff size %d\n\r", temp.size());
+    pc.printf("\n\r%d %d\n\r", temp._head, temp._tail);
+    
     // Initialize the uLCD
-    uLCD.baudrate(3000000);
-    uLCD.background_color(BLACK);
+    //uLCD.baudrate(3000000);
+    //uLCD.background_color(BLACK);
     
     // Spawn threads
     lcd.start(lcdThread);
@@ -202,13 +226,14 @@
     
     // Setup the button to enter transmit mode when pushed down
     // and recieve when release
-    button.mode(PullDown);
-    button.fall(&enterTransmitMode);
-    button.rise(&enterRecieveMode);
+    button.mode(PullUp);
+    //button.fall(&enterTransmitMode);
+    //button.rise(&enterRecieveMode);
     
     // Setup sampler to sample at a specific frequency
-    sampler.attach(&sampleData, SAMPLE_PERIOD);
+    //sampler.attach(&sampleData, SAMPLE_PERIOD);
     
+    pc.printf("Enter Heartbeat\n\r");
     // Heartbeat thread
     while (1) {
         myled4 = !myled4;