no description

Fork of Middleware by Roberto Herrera

Committer:
Jorge_Beltran
Date:
Mon Dec 07 01:50:01 2015 +0000
Revision:
1:32a08ca33b00
SensorsForGusProject

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jorge_Beltran 1:32a08ca33b00 1 #include "Sensors.h"
Jorge_Beltran 1:32a08ca33b00 2 #include "Initial.h"
Jorge_Beltran 1:32a08ca33b00 3
Jorge_Beltran 1:32a08ca33b00 4
Jorge_Beltran 1:32a08ca33b00 5 /*Functions*/
Jorge_Beltran 1:32a08ca33b00 6
Jorge_Beltran 1:32a08ca33b00 7 //PRESCENCE DETECTION FUNCTION
Jorge_Beltran 1:32a08ca33b00 8 bool GetPrescenceStatus(){
Jorge_Beltran 1:32a08ca33b00 9 static bool RoomStatus = FALSE;
Jorge_Beltran 1:32a08ca33b00 10
Jorge_Beltran 1:32a08ca33b00 11 if(PIR1==TRUE || PIR2==TRUE)
Jorge_Beltran 1:32a08ca33b00 12 {
Jorge_Beltran 1:32a08ca33b00 13 RoomStatus = TRUE;
Jorge_Beltran 1:32a08ca33b00 14 }
Jorge_Beltran 1:32a08ca33b00 15 else
Jorge_Beltran 1:32a08ca33b00 16 {
Jorge_Beltran 1:32a08ca33b00 17 RoomStatus = FALSE;
Jorge_Beltran 1:32a08ca33b00 18 }
Jorge_Beltran 1:32a08ca33b00 19
Jorge_Beltran 1:32a08ca33b00 20 return RoomStatus;
Jorge_Beltran 1:32a08ca33b00 21 }
Jorge_Beltran 1:32a08ca33b00 22
Jorge_Beltran 1:32a08ca33b00 23 //DOOR STATUS FUNCION
Jorge_Beltran 1:32a08ca33b00 24 bool GetDoorStatus(){
Jorge_Beltran 1:32a08ca33b00 25 static bool DoorStatus = CLOSED;
Jorge_Beltran 1:32a08ca33b00 26
Jorge_Beltran 1:32a08ca33b00 27 if(DOORSensor == TRUE)
Jorge_Beltran 1:32a08ca33b00 28 DoorStatus = OPEN;
Jorge_Beltran 1:32a08ca33b00 29 else
Jorge_Beltran 1:32a08ca33b00 30 DoorStatus = CLOSED;
Jorge_Beltran 1:32a08ca33b00 31
Jorge_Beltran 1:32a08ca33b00 32 return DoorStatus;
Jorge_Beltran 1:32a08ca33b00 33 }
Jorge_Beltran 1:32a08ca33b00 34
Jorge_Beltran 1:32a08ca33b00 35
Jorge_Beltran 1:32a08ca33b00 36 //WINDOW STATUS FUNCTION
Jorge_Beltran 1:32a08ca33b00 37 int GetWindowStatus(int window){
Jorge_Beltran 1:32a08ca33b00 38 static int WindowStatus = CLOSED;
Jorge_Beltran 1:32a08ca33b00 39
Jorge_Beltran 1:32a08ca33b00 40 switch(window)
Jorge_Beltran 1:32a08ca33b00 41 {
Jorge_Beltran 1:32a08ca33b00 42 case 1:
Jorge_Beltran 1:32a08ca33b00 43 if(W1)
Jorge_Beltran 1:32a08ca33b00 44 WindowStatus = OPEN;
Jorge_Beltran 1:32a08ca33b00 45 else
Jorge_Beltran 1:32a08ca33b00 46 WindowStatus = CLOSED;
Jorge_Beltran 1:32a08ca33b00 47 break;
Jorge_Beltran 1:32a08ca33b00 48 case 2:
Jorge_Beltran 1:32a08ca33b00 49 if(W2)
Jorge_Beltran 1:32a08ca33b00 50 WindowStatus = OPEN;
Jorge_Beltran 1:32a08ca33b00 51 else
Jorge_Beltran 1:32a08ca33b00 52 WindowStatus = CLOSED;
Jorge_Beltran 1:32a08ca33b00 53 break;
Jorge_Beltran 1:32a08ca33b00 54 case 3:
Jorge_Beltran 1:32a08ca33b00 55 if(W3)
Jorge_Beltran 1:32a08ca33b00 56 WindowStatus = OPEN;
Jorge_Beltran 1:32a08ca33b00 57 else
Jorge_Beltran 1:32a08ca33b00 58 WindowStatus = CLOSED;
Jorge_Beltran 1:32a08ca33b00 59 break;
Jorge_Beltran 1:32a08ca33b00 60 default:
Jorge_Beltran 1:32a08ca33b00 61 WindowStatus = BAD_PARAMETER;
Jorge_Beltran 1:32a08ca33b00 62 break;
Jorge_Beltran 1:32a08ca33b00 63 }
Jorge_Beltran 1:32a08ca33b00 64
Jorge_Beltran 1:32a08ca33b00 65 return WindowStatus;
Jorge_Beltran 1:32a08ca33b00 66 }
Jorge_Beltran 1:32a08ca33b00 67
Jorge_Beltran 1:32a08ca33b00 68 //LIGHT CONTROL FUNCTION
Jorge_Beltran 1:32a08ca33b00 69 int SetLight(bool Light){
Jorge_Beltran 1:32a08ca33b00 70 static int LightStatus = 0;
Jorge_Beltran 1:32a08ca33b00 71
Jorge_Beltran 1:32a08ca33b00 72 switch(Light)
Jorge_Beltran 1:32a08ca33b00 73 {
Jorge_Beltran 1:32a08ca33b00 74 case 0:
Jorge_Beltran 1:32a08ca33b00 75 LightStatus = OFF;
Jorge_Beltran 1:32a08ca33b00 76 LightControl = OFF;
Jorge_Beltran 1:32a08ca33b00 77 break;
Jorge_Beltran 1:32a08ca33b00 78 case 1:
Jorge_Beltran 1:32a08ca33b00 79 LightStatus = ON;
Jorge_Beltran 1:32a08ca33b00 80 LightControl = ON;
Jorge_Beltran 1:32a08ca33b00 81 break;
Jorge_Beltran 1:32a08ca33b00 82 default:
Jorge_Beltran 1:32a08ca33b00 83 LightStatus = BAD_PARAMETER;
Jorge_Beltran 1:32a08ca33b00 84 break;
Jorge_Beltran 1:32a08ca33b00 85 }
Jorge_Beltran 1:32a08ca33b00 86
Jorge_Beltran 1:32a08ca33b00 87 return LightStatus;
Jorge_Beltran 1:32a08ca33b00 88 }
Jorge_Beltran 1:32a08ca33b00 89
Jorge_Beltran 1:32a08ca33b00 90 //PERSON COUNTER FUNCTION
Jorge_Beltran 1:32a08ca33b00 91 unsigned int GetPersonStatus(){
Jorge_Beltran 1:32a08ca33b00 92 static unsigned int PersonNumber = 0;
Jorge_Beltran 1:32a08ca33b00 93
Jorge_Beltran 1:32a08ca33b00 94 //TODO Insert code here
Jorge_Beltran 1:32a08ca33b00 95 /*** TODO ***/
Jorge_Beltran 1:32a08ca33b00 96 /*** TODO ***/
Jorge_Beltran 1:32a08ca33b00 97 /*** TODO ***/
Jorge_Beltran 1:32a08ca33b00 98
Jorge_Beltran 1:32a08ca33b00 99 return PersonNumber;
Jorge_Beltran 1:32a08ca33b00 100 }