no description

Fork of Middleware by Roberto Herrera

SensorPIR.cpp

Committer:
RoHe
Date:
2015-12-05
Revision:
0:d1ff330c5128

File content as of revision 0:d1ff330c5128:

/*

Drivers.cpp

Only to improve the clarity of main .cpp
This don't have any new classes

All the multiple task are here 
for Smart Room project asked by 
Gustavo Torres 

Last update by RoHe 16/11/2015

*/

#include "SensorPIR.h"

Drivers::Drivers()
{
    varInt=5;
}

bool Drivers::is_good(void)
{
    return true;
}

int Drivers::getVar(void)
{
    return varInt;
}

char* Drivers::echo(void)
{
    return "Hello from Library";
}
 
/*Defines*/
//Serial UARTPIR(USBTX, USBRX);
//DigitalOut dout(LED1);
//DigitalIn enable2(D1);
//DigitalIn enable3(D2);
//DigitalIn enable4(D3);
 
/*Functions*/
int GetPersonStatus(int RoomPrescence) {
    bool print = 0;
    bool RoomStatus = 0;   
    wait(2); //Wait for sensor to take snap shot of still room
    
    switch(RoomPrescence)
    {
      case 1:
            if(enable1==1 /*|| enable2==1 || enable3==1 || enable4==1*/)
            {
                RoomStatus = 1;
                ledGREEN=1;
                if(print == 0)
                {
                    pc.printf("Presencia detectada\n\r");
                    print = 1;
                }
            }
            else
            {
                RoomStatus = 0;
                ledGREEN=0;
                if(print == 1)
                {
                    pc.printf("Ninguna presencia detectada\n\r");
                    print = 0;
                }
            }
            break;
            
        case 2:
        /*ADD NEW ROOM*/
            break;
            
        default:
        /*Do Nothing*/
            break;
    }
    return RoomStatus;
}