Home automation using Xbee radios

Dependencies:   EthernetNetIf HTTPServer RPCInterface mbed C12832_lcd

Link to Notebook Page

Files at this revision

API Documentation at this revision

Comitter:
chrisisthefish
Date:
Mon Dec 09 01:44:25 2013 +0000
Parent:
10:de0be690b3c0
Commit message:
Added support for Mbed application board LCD screen.; Added support for displaying IP address and status on LCD screen.

Changed in this revision

XbeeCommLib.h 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
diff -r de0be690b3c0 -r 03ff417d0d5d XbeeCommLib.h
--- a/XbeeCommLib.h	Fri Dec 06 07:05:49 2013 +0000
+++ b/XbeeCommLib.h	Mon Dec 09 01:44:25 2013 +0000
@@ -30,6 +30,7 @@
 
 void compareDigitalReadWrite();
 void monitorTimers();
+void lcdDisplay();
 
 //void up( void );
 //void down( void );
diff -r de0be690b3c0 -r 03ff417d0d5d main.cpp
--- a/main.cpp	Fri Dec 06 07:05:49 2013 +0000
+++ b/main.cpp	Mon Dec 09 01:44:25 2013 +0000
@@ -19,6 +19,7 @@
 #include "HTTPServer.h"
 #include "SerialRPCInterface.h"
 #include "XbeeCommLib.h"
+#include "C12832_lcd.h"
 
 DigitalIn pb(p8);
 DigitalOut led1(LED1);
@@ -27,6 +28,7 @@
 DigitalOut led4(LED4);
 
 Serial xbeeSerial(p9, p10);
+C12832_LCD lcd;
 
 unsigned char data[500];
 int dataCounter = 0;
@@ -76,6 +78,7 @@
 
 EthernetNetIf eth;  
 HTTPServer svr;
+IpAddr Ip;
 
 
 
@@ -128,9 +131,7 @@
 
 
 int main() {
-    
-    //xbeeSerial.attach(&xbeeSerialHandler);
-    
+ 
     printf("\n\nBeginning Setup\n");
     // Ethernet Setup
     EthernetErr ethErr = eth.setup();
@@ -140,13 +141,17 @@
     }
     printf("Setup OK\n");
     
+    Ip = eth.getIp();
+    lcd.cls();
+    lcd.printf("IP Address: %d.%d.%d.%d\r\n", Ip[0], Ip[1], Ip[2], Ip[3]);
+    
     // Add RPCHandler
     svr.addHandler<RPCHandler>("/rpc");
     
     // Show that the server is ready and listening
     svr.bind(80);
     printf("RPC Server Ready\n");
-
+    
 
     xbeeList[0].addrHigh = 0x0013a200;
     xbeeList[0].addrLow = 0x4079d00b; //Router0
@@ -210,7 +215,7 @@
         if(tm.read() > 1){
             led1 = !led1;
             tm.start();
-            
+            lcdDisplay();
             
         }
     }
@@ -444,3 +449,38 @@
         }
     }
 }
+
+
+
+void lcdDisplay(){
+    int tempCount = 0;
+    int lightCount = 0;
+//    lcd.cls();
+//    lcd.locate(0,0);
+//    lcd.printf("IP Address: %d.%d.%d.%d\r\n", Ip[0], Ip[1], Ip[2], Ip[3]);
+    
+    for(int i = 0; i < xbeeCount; i++){
+        for(int j = 0; j < 4; j++){
+            if(xbeeList[i].analogRpcDataPointer[j] != NULL){
+                lcd.locate(0,(tempCount*10)+10);
+                lcd.printf("            ");
+                lcd.locate(0,(tempCount*10)+10);
+                lcd.printf("Temp%d: %4.2fF", i, *xbeeList[i].analogRpcDataPointer[j]);
+                tempCount++;
+                break;
+            }
+        }
+        
+        if(xbeeList[i].rpcDataPointer[0] != NULL && xbeeList[i].digitalType[0] == 1){
+            lcd.locate(70,(lightCount*10)+10);
+            lcd.printf("            ", i);
+            lcd.locate(70,(lightCount*10)+10);
+            if(*xbeeList[i].rpcDataPointer[0]){
+                lcd.printf("Light%d: On", i);
+            }else{
+                lcd.printf("Light%d: Off", i);
+            }
+            lightCount++;
+        }
+    }
+}
\ No newline at end of file