pepe
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "alarma.h" 00003 00004 AnalogIn Ref(p19); //Pot 1 00005 DigitalIn Pulsador(p14); //Joystick Center 00006 DigitalOut Buzzer(p29); //Sirena 00007 AnalogIn Valor(p20); //Pot 2 (Sensor Analogo) 00008 DigitalOut Alive(LED2); //KeepAlive signal 00009 DigitalOut Indicador(LED1); //LED de encendido 00010 DigitalOut Luz(p23); //RGB red 00011 DigitalIn Estado(p21); //Sensor Digital 00012 00013 int i=0; 00014 int Titila = 1; 00015 int On = 2; 00016 int Off = 3; 00017 bool check = true; 00018 bool testResult = false; 00019 int delaySirena = 1; //Factory configuration. 00020 int testSirena = 1; 00021 int delayLuz = 1; //Factory configuration. 00022 int delayFactory = 2; //Factory configuration. 00023 int AStatus = 0; 00024 int DStatus = 0; 00025 int An = 0; 00026 int Di = 0; 00027 int Prog; 00028 int Auto = 1; //Armado automático al encender. 00029 00030 int main() { 00031 Luz = 1; 00032 Prog = 1; 00033 Auto = 1; 00034 while(true){ 00035 if(check == true) 00036 testResult = Test(); 00037 while(testResult == 0){ 00038 Luz = 1; 00039 LED(Titila); 00040 KeepAlive(); 00041 if(Pulsador == true){ 00042 wait(5); 00043 if(Pulsador == true){ 00044 check = 1; //Test habilitado. 00045 break; 00046 } 00047 } 00048 } 00049 while(testResult){ 00050 Luz = 1; 00051 if(Pulsador == true){ 00052 wait(5); 00053 if(Pulsador == true){ 00054 Config(); //Modo programación en Fábrica. 00055 } 00056 } 00057 Prog = 0; //Deshabilito modo programación hasta resetear. 00058 LED(On); 00059 while((Pulsador == false)&&(Auto != 1)){ //Esperando armado. 00060 KeepAlive(); 00061 } 00062 Auto = 0; 00063 wait(0.05); 00064 for(i=0;i<10;i++){ //Pulsador presionado > 5s => Test(). 00065 if(Pulsador){ 00066 wait(0.5); 00067 check = true; //Test habilitado. 00068 } 00069 else { 00070 check = false; 00071 Armar(); 00072 break; 00073 } 00074 } 00075 if(check == true) 00076 break; //Go to Test. 00077 } 00078 } 00079 }
Generated on Wed Jul 27 2022 00:30:41 by
1.7.2