Pedro Colla / Mbed 2 deprecated CTo_VyV_TPAlarma

Dependencies:   mbed

Revision:
0:f42f18c56a88
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 16 00:48:19 2013 +0000
@@ -0,0 +1,79 @@
+#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.
+        }              
+    }
+}
\ No newline at end of file