mbed Sensor node for Instrumented Booth over ETH.

Dependencies:   EthernetInterface-1 MaxbotixDriver Presence HTU21D_TEMP_HUMID_SENSOR_SAMPLE Resources SHARPIR mbed-rtos mbed-src WDT_K64F nsdl_lib

Fork of Trenton_Switch_LPC1768_ETH by Demo Team

Revision:
27:6017a643f386
Parent:
26:4cac6b346e4f
Child:
28:908a6f58aa7f
--- a/sensor_ctl.cpp	Wed Dec 03 15:39:09 2014 +0000
+++ b/sensor_ctl.cpp	Wed Dec 03 17:33:34 2014 +0000
@@ -8,24 +8,34 @@
 #include "RHT03.h"
 #include "MAX9814.h"
 #include "sonar.h"
-#include "PIR.h"
+#include "Presence.h"
 #include "SHARPIR.h"
 
 //Sensor MDS Resources
 #include "door_trip.h"
 #include "height.h"
-#include "kiosk_presence.h"
-#include "motion.h"
+#include "presence_resource.h"
 #include "sound_level.h"
 #include "temperature.h"
 
 //Common Sensors
+#if NODE_SENSOR_STATION
 RHT03 temperature(PTB2);
 MAX9814 microphone(PTB3); //Analogue in required.
+#if NODE_PIR_STATION
+Presence pir(PTB11, false, 5000); //(InterruptPin), for PIR sensor, 
+#endif //NODE PIR STATION
+#if NODE_KIOSK_STATION
+Presence kiosk(PTB10, true, 500); //(Interrupt pinrequired, no timeout)
+#endif //NODE KIOSK STATION
+#if NODE_DOOR_TRIP_STATION
+SHARPIR sharpir(PTC11); //(AnalogIn required), for IR door trip
+#endif //NODE TRIP STATION
+#if NODE_HEIGHT_STATION
 Timer sonarTimer;
 Sonar Sonar(PTB10, sonarTimer); //(AnalogIn required, Leave as SW2.)
-PIR pir(PTB11); //(InterruptPin), for PIR sensor, 
-SHARPIR sharpir(PTC11); //(AnalogIn required), for IR door trip
+#endif //NODE HEIGHT STATION
+#endif //NODE_SENSOR_STATION
 
 
 //Variables provided to rest of applications
@@ -34,7 +44,6 @@
 //Either height XOR kiosk presence XOR PIR station...
 float    current_door_height_value = 0;
 bool     current_presence_value = false;         //Either from Kiosk or PIR
-#define KIOSK_MAX_RANGE 200; //Max range, centimetres...
 //And it might have a door trip..
 bool     current_door_trip_value = false;
 
@@ -46,8 +55,6 @@
     //Start the sonar pulse width timer...
     #if NODE_HEIGHT_STATION
     sonarTimer.start();
-    #elif NODE_KIOSK_STATION
-    sonarTimer.start();
     #endif
     
     #if NODE_DOOR_TRIP_STATION
@@ -55,6 +62,8 @@
     #endif
 }
 
+#if NODE_SENSOR_STATION
+
 //timer handler functions
 void handle_temperature_report_timer() {
     if(temperature.readData() == RHT_ERROR_NONE) { 
@@ -84,33 +93,37 @@
     current_ambient_noise_value = 0;
 }
 
+#if NODE_HEIGHT_STATION
 void handle_door_height_sample_timer()
 {
 
 }
+#endif //NODE_HEIGHT_STATION
 
+#if NODE_PIR_STATION
 void handle_motion_report_timer(){
-    bool new_pir = pir.getdetection();
+    bool new_pir = pir.isPresent();
     //printf("PIR Sample: %d\r\n", new_pir);
     //printf("Old PIR Sample: %d\r\n", current_presence_value);
     if(new_pir != current_presence_value) {
         //printf("Reporting PIR...\r\n");
         current_presence_value = new_pir;
-        motion_report();
+        presence_report();
     }
 }
-
+#endif //NODE_PIR_STATION
 
-DigitalOut led1(LED1);
+#if NODE_KIOSK_STATION
 void handle_kiosk_report_timer(){
-    bool new_kiosk = Sonar.read() < KIOSK_MAX_RANGE;
+    bool new_kiosk = kiosk.isPresent();
     if(new_kiosk != current_presence_value) {
         current_presence_value = new_kiosk;
-        if(current_presence_value) led1 = 1; else led1 = 0;
-        kiosk_presence_report();
+        presence_report();
     }
 }
+#endif //NODE_KIOSK_STATION
 
+#if NODE_DOOR_TRIP_STATION
 void handle_door_trip_report_timer(){
     float value= sharpir.volt();
     bool new_door_trip = 0;
@@ -125,9 +138,10 @@
         door_trip_report();
     }
 }
+#endif //NODE_DOOR_TRIP_STATION
 
-void drive_height()
-{
+#if NODE_HEIGHT_STATION
+void drive_height(){
 //    current_height_value=/*obj*/.data_conversion_m();
 //    
 //    if(current_height_value>1) {
@@ -145,17 +159,5 @@
 
 }
 
-
-
-void drive_kiosk_presence()
-{
-//
-//    if (kiosk.getdetection()) {
-//        current_kiosk_presence_value=1;
-//    }
-//
-//    else current_kiosk_presence_value=0;
-//    
-//    if (last_reported_kiosk_presence != current_kiosk_presence)
-//        kiosk_presence_report();
-}
\ No newline at end of file
+#endif //NODE HEIGHT STATION
+#endif //NODE_SENSOR_STATION
\ No newline at end of file