This is my final project for UCSC Extension - USB Programming. It is a home monitoring program for motion and temperature and requires host-side code.

Dependencies:   C12832_lcd HomeMon LM75B MMA7660 USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
groletter
Date:
Tue Sep 03 08:55:16 2013 +0000
Parent:
1:289ca384fc67
Child:
3:21245644a2e3
Commit message:
A couple bug fixes. Should be final for the final class.

Changed in this revision

HomeMon.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
--- a/HomeMon.lib	Sun Sep 01 23:43:10 2013 +0000
+++ b/HomeMon.lib	Tue Sep 03 08:55:16 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/groletter/code/HomeMon/#3f846fc933a2
+http://mbed.org/users/groletter/code/HomeMon/#2f5a62eb52ad
--- a/main.cpp	Sun Sep 01 23:43:10 2013 +0000
+++ b/main.cpp	Tue Sep 03 08:55:16 2013 +0000
@@ -55,7 +55,7 @@
 DigitalOut connectionLED(LED1);
 DigitalOut motionLED(LED2);
 DigitalOut tempHiLED(LED3);
-DigitalOut tempLoLED(LED3);
+DigitalOut tempLoLED(LED4);
 
 // Global State       
 int state;
@@ -79,6 +79,7 @@
         // FIXME - for debug 
         lcd.cls();
         lcd.locate(0,3);
+        lcd.printf("Motion detected - sending alert!\n");
         lcd.printf("x = %.2f y = %.2f z = %.2f\n", delta.x, delta.y, delta.z);  
         return true;  
         
@@ -152,6 +153,9 @@
         if (state == monDISCONNECTED) {
             if (check_connection()) {
                 connectionLED = 1;
+                lcd.cls();
+                lcd.locate(0,3);
+                lcd.printf("Connected to Host\n");
                 state = monCONNECTED;
                 if (alertState.pendMotion) {
                     alertState.pendMotion = false;
@@ -159,14 +163,17 @@
                 }
                 else if (alertState.pendTempHi) {
                     alertState.pendTempHi = false;
-                    send_alert(MOTION);
+                    send_alert(TEMP_HI);
                 }
                 else if (alertState.pendTempLo) {
                     alertState.pendTempLo = false;
-                    send_alert(MOTION);
+                    send_alert(TEMP_LOW);
                 }
             }
             else {
+                lcd.cls();
+                lcd.locate(0,3);
+                lcd.printf("Not Connected to Host\n");
                 connectionLED = 0;
             }
         }
@@ -212,6 +219,9 @@
         theTemp = get_temp();
         if (theTemp > myTemp.get_max()) {
           if (sysMonTime.read() > (lastTempAlertSecs + TempAlertWaitSecs)) {
+            lcd.cls();
+            lcd.locate(0,3);
+            lcd.printf("TEMP ALERT %.2f over %.2f - sending alert!\n", theTemp, myTemp.get_max()); 
             tempHiLED = 1;
             if (state == monCONNECTED) {
                 send_alert(TEMP_HI);
@@ -226,6 +236,9 @@
         }
         else if (theTemp < myTemp.get_min()) {
           if (sysMonTime.read() > (lastTempAlertSecs + TempAlertWaitSecs)) {
+            lcd.cls();
+            lcd.locate(0,3);
+            lcd.printf("TEMP ALERT %.2f under %.2f - sending alert!\n", theTemp, myTemp.get_min()); 
             tempLoLED = 1;
             if (state == monCONNECTED) {
                 send_alert(TEMP_LOW);
@@ -241,7 +254,7 @@
         
         // See if it is time to store the temperature samples
         if (sysMonTime.read_ms()/MS_IN_SEC > (lastTimeMS + myTemp.get_period())) {
-            lcd.printf("time to send temperature\n");
+            // DEBUG lcd.printf("time to send temperature\n");
             lastTimeMS = sysMonTime.read_ms()/MS_IN_SEC;
             myTemp.add_sample(get_temp());
         }