ECE 4180 - Final Project Team / Mbed 2 deprecated WalkieTalkie

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

Revision:
21:95009b231c1f
Parent:
20:e068469ffb89
Child:
22:e835b3490280
--- a/main.cpp	Fri Apr 20 18:39:20 2018 +0000
+++ b/main.cpp	Sat Apr 21 16:47:02 2018 +0000
@@ -5,6 +5,7 @@
 #include "Speaker.h"
 #include "HUD.h"
 #include "nRF24L01P.h"
+#include "uLCD_4DGL.h"
 
 #include "CircularBuf.h"
 #include "CircularBuf.cpp" // Hack to get templates to work
@@ -21,11 +22,13 @@
 Microphone mymicrophone(p16);
 
 nRF24L01P my_nrf24l01p(p5, p6, p7, p8, p9, p10);    // mosi, miso, sck, csn, ce, irq
+uLCD_4DGL uLCD(p27,p28,p30);                        // serial tx, serial rx, reset pin;
 CircularBuf<uint8_t> txbuff(30);
 CircularBuf<uint8_t> rxbuff(30);
 
 Ticker t; //10:41 am 4/20
 InterruptIn Button(p20); //changed DitialIn to InterruptIn at 5:54 4/18/18
+Thread lcd;
 
 char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE]; //making these usable by other voids.
 int txDataCnt = 0;//and this.
@@ -33,6 +36,18 @@
 uint8_t micvalue[30];
 int micvalcount = 0;
 
+int rfFreq;
+int dataRate;
+unsigned long long rxAddr, txAddr;
+
+enum operatingMode {
+    RECEIVE = 0,
+    TRANSMIT
+};
+
+operatingMode mode;
+
+
 void startup()
 {
 
@@ -134,11 +149,58 @@
 
 }
 
+void lcdThread()
+{
+    while (1) {
+        uLCD.locate(64, 20);
+        uLCD.printf("Frequency: %d MHz", rfFreq);
+        uLCD.locate(64, 40);
+        uLCD.printf("Data Rate: %d kbps", dataRate);
+        uLCD.locate(64, 60);
+        uLCD.printf("TX Address: 0x%010llX", txAddr);
+        uLCD.locate(64, 80);
+        uLCD.printf("RX Address: 0x%010llX", rxAddr);
+        uLCD.locate(64, 100);
+        switch (mode) {
+            case RECEIVE:
+                uLCD.printf("Mode: Receiving");
+                break;
+            case TRANSMIT:
+                uLCD.printf("Mode: Transmitting");
+                break;
+        }
+        // Maybe add some graphics too idk
+    }
+}
+
 int main()
 {
+    // Initialize the radio trasceiver
+    my_nrf24l01p.powerUp();
+    
+    rfFreq = my_nrf24l01p.getRfFrequency();
+    dataRate = my_nrf24l01p.getAirDataRate();
+    rxAddr = my_nrf24l01p.getRxAddress();
+    txAddr = my_nrf24l01p.getTxAddress();
+    
+    my_nrf24l01p.setTransferSize(TRANSFER_SIZE);
+
+    my_nrf24l01p.setReceiveMode();
+    my_nrf24l01p.enable();
+    
+    // Initialize the uLCD
+    uLCD.baudrate(3000000);
+    uLCD.background_color(BLACK);
+    
+    // Register interrupts
     Button.mode(PullUp);//added 6:23pm 4/18/18
     t.attach(&pollmic, 0.0001);
     t.attach(&receive, 0.0001);
+    
+    // Spawn threads
+    lcd.start(lcdThread);
+    
+    // Main thread
     while (1) {
 
     }