no description

Fork of Middleware by Roberto Herrera

Committer:
RoHe
Date:
Sat Dec 05 17:43:29 2015 +0000
Revision:
0:d1ff330c5128
MiddleWare GUS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RoHe 0:d1ff330c5128 1 /*
RoHe 0:d1ff330c5128 2
RoHe 0:d1ff330c5128 3 Drivers.cpp
RoHe 0:d1ff330c5128 4
RoHe 0:d1ff330c5128 5 Only to improve the clarity of main .cpp
RoHe 0:d1ff330c5128 6 This don't have any new classes
RoHe 0:d1ff330c5128 7
RoHe 0:d1ff330c5128 8 All the multiple task are here
RoHe 0:d1ff330c5128 9 for Smart Room project asked by
RoHe 0:d1ff330c5128 10 Gustavo Torres
RoHe 0:d1ff330c5128 11
RoHe 0:d1ff330c5128 12 Last update by RoHe 16/11/2015
RoHe 0:d1ff330c5128 13
RoHe 0:d1ff330c5128 14 */
RoHe 0:d1ff330c5128 15
RoHe 0:d1ff330c5128 16 #include "SensorPIR.h"
RoHe 0:d1ff330c5128 17
RoHe 0:d1ff330c5128 18 Drivers::Drivers()
RoHe 0:d1ff330c5128 19 {
RoHe 0:d1ff330c5128 20 varInt=5;
RoHe 0:d1ff330c5128 21 }
RoHe 0:d1ff330c5128 22
RoHe 0:d1ff330c5128 23 bool Drivers::is_good(void)
RoHe 0:d1ff330c5128 24 {
RoHe 0:d1ff330c5128 25 return true;
RoHe 0:d1ff330c5128 26 }
RoHe 0:d1ff330c5128 27
RoHe 0:d1ff330c5128 28 int Drivers::getVar(void)
RoHe 0:d1ff330c5128 29 {
RoHe 0:d1ff330c5128 30 return varInt;
RoHe 0:d1ff330c5128 31 }
RoHe 0:d1ff330c5128 32
RoHe 0:d1ff330c5128 33 char* Drivers::echo(void)
RoHe 0:d1ff330c5128 34 {
RoHe 0:d1ff330c5128 35 return "Hello from Library";
RoHe 0:d1ff330c5128 36 }
RoHe 0:d1ff330c5128 37
RoHe 0:d1ff330c5128 38 /*Defines*/
RoHe 0:d1ff330c5128 39 //Serial UARTPIR(USBTX, USBRX);
RoHe 0:d1ff330c5128 40 //DigitalOut dout(LED1);
RoHe 0:d1ff330c5128 41 //DigitalIn enable2(D1);
RoHe 0:d1ff330c5128 42 //DigitalIn enable3(D2);
RoHe 0:d1ff330c5128 43 //DigitalIn enable4(D3);
RoHe 0:d1ff330c5128 44
RoHe 0:d1ff330c5128 45 /*Functions*/
RoHe 0:d1ff330c5128 46 int GetPersonStatus(int RoomPrescence) {
RoHe 0:d1ff330c5128 47 bool print = 0;
RoHe 0:d1ff330c5128 48 bool RoomStatus = 0;
RoHe 0:d1ff330c5128 49 wait(2); //Wait for sensor to take snap shot of still room
RoHe 0:d1ff330c5128 50
RoHe 0:d1ff330c5128 51 switch(RoomPrescence)
RoHe 0:d1ff330c5128 52 {
RoHe 0:d1ff330c5128 53 case 1:
RoHe 0:d1ff330c5128 54 if(enable1==1 /*|| enable2==1 || enable3==1 || enable4==1*/)
RoHe 0:d1ff330c5128 55 {
RoHe 0:d1ff330c5128 56 RoomStatus = 1;
RoHe 0:d1ff330c5128 57 ledGREEN=1;
RoHe 0:d1ff330c5128 58 if(print == 0)
RoHe 0:d1ff330c5128 59 {
RoHe 0:d1ff330c5128 60 pc.printf("Presencia detectada\n\r");
RoHe 0:d1ff330c5128 61 print = 1;
RoHe 0:d1ff330c5128 62 }
RoHe 0:d1ff330c5128 63 }
RoHe 0:d1ff330c5128 64 else
RoHe 0:d1ff330c5128 65 {
RoHe 0:d1ff330c5128 66 RoomStatus = 0;
RoHe 0:d1ff330c5128 67 ledGREEN=0;
RoHe 0:d1ff330c5128 68 if(print == 1)
RoHe 0:d1ff330c5128 69 {
RoHe 0:d1ff330c5128 70 pc.printf("Ninguna presencia detectada\n\r");
RoHe 0:d1ff330c5128 71 print = 0;
RoHe 0:d1ff330c5128 72 }
RoHe 0:d1ff330c5128 73 }
RoHe 0:d1ff330c5128 74 break;
RoHe 0:d1ff330c5128 75
RoHe 0:d1ff330c5128 76 case 2:
RoHe 0:d1ff330c5128 77 /*ADD NEW ROOM*/
RoHe 0:d1ff330c5128 78 break;
RoHe 0:d1ff330c5128 79
RoHe 0:d1ff330c5128 80 default:
RoHe 0:d1ff330c5128 81 /*Do Nothing*/
RoHe 0:d1ff330c5128 82 break;
RoHe 0:d1ff330c5128 83 }
RoHe 0:d1ff330c5128 84 return RoomStatus;
RoHe 0:d1ff330c5128 85 }