2-way comms for mbed appBoard and Xbees

Dependencies:   mbed C12832_lcd

Files at this revision

API Documentation at this revision

Comitter:
dannellyz
Date:
Sun Feb 15 04:47:03 2015 +0000
Parent:
1:2513e17b33db
Commit message:
added LCD

Changed in this revision

C12832_lcd.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832_lcd.lib	Sun Feb 15 04:47:03 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/dreschpe/code/C12832_lcd/#8f86576007d6
--- a/main.cpp	Sun Feb 15 04:23:16 2015 +0000
+++ b/main.cpp	Sun Feb 15 04:47:03 2015 +0000
@@ -7,6 +7,7 @@
 //Code to send and recieve serial comms on 
 //mbed appBoard with xbees
 #include "mbed.h"
+#include "C12832_lcd.h" // Include for LCD code
 
 //Initialize xbee
 Serial xbee(p9, p10);
@@ -14,20 +15,32 @@
 
 //Initialize terminal
 Serial pc(USBTX, USBRX);
+
+//Initialize lcd
+C12832_LCD lcd;
  
 int main() {
- 
     // reset the xbees (at least 200ns)
     rst1 = 0;
     wait_ms(1); 
     rst1 = 1;
-    wait_ms(1); 
+    wait_ms(1);
+    //Setup LCD screen
+    lcd.cls();                                          //...they want to see which parameters they want to edit
+    lcd.locate(0,1);
     while(1) {
+        //variable to get data from xbee
+        char toPrint;
+        
+        //If terminal data available send through xbee
         if(pc.readable()) {
             xbee.putc(pc.getc());
         }
+        //If xbee gets data send to terminal and lcd screen
         if(xbee.readable()) {
-            pc.putc(xbee.getc();
+            toPrint = xbee.getc();
+            pc.putc(toPrint);
+            lcd.printf("%c",toPrint);
         }
     }
 }
\ No newline at end of file