Pedro Colla / Mbed 2 deprecated CTo_VyV_TPAlarma

Dependencies:   mbed

main.cpp

Committer:
pcolla
Date:
2013-11-16
Revision:
0:f42f18c56a88

File content as of revision 0:f42f18c56a88:

#include "mbed.h"
#include "alarma.h"

AnalogIn    Ref(p19);                   //Pot 1
DigitalIn   Pulsador(p14);              //Joystick Center
DigitalOut  Buzzer(p29);                //Sirena
AnalogIn    Valor(p20);                 //Pot 2 (Sensor Analogo)
DigitalOut  Alive(LED2);                //KeepAlive signal
DigitalOut  Indicador(LED1);            //LED de encendido
DigitalOut  Luz(p23);                   //RGB red
DigitalIn   Estado(p21);                //Sensor Digital

int     i=0;
int     Titila = 1;
int     On = 2;
int     Off = 3;
bool    check = true;
bool    testResult = false;
int     delaySirena = 1;              //Factory configuration.           
int     testSirena = 1;
int     delayLuz = 1;                 //Factory configuration.
int     delayFactory = 2;               //Factory configuration.
int     AStatus = 0;
int     DStatus = 0;
int     An = 0;
int     Di = 0;
int     Prog;
int     Auto = 1;                       //Armado automático al encender.

int main() {
    Luz = 1;
    Prog = 1;
    Auto = 1;
    while(true){
        if(check == true)
            testResult = Test();
        while(testResult == 0){
            Luz = 1;
            LED(Titila);
            KeepAlive();
            if(Pulsador == true){
                wait(5);
                if(Pulsador == true){
                    check = 1;              //Test habilitado.
                    break;
                }
            }
        }
        while(testResult){
            Luz = 1;
            if(Pulsador == true){
                wait(5);
                if(Pulsador == true){
                    Config();               //Modo programación en Fábrica.
                }
            }
            Prog = 0;                       //Deshabilito modo programación hasta resetear.
            LED(On);
            while((Pulsador == false)&&(Auto != 1)){       //Esperando armado.
                KeepAlive();
            }  
            Auto = 0;  
            wait(0.05);
            for(i=0;i<10;i++){              //Pulsador presionado > 5s => Test().
                if(Pulsador){
                    wait(0.5);              
                    check = true;           //Test habilitado.
                }
                else {   
                    check = false;
                    Armar();
                    break;
                }
            }
            if(check == true)
                break;                      //Go to Test.
        }              
    }
}