Tarea Reloj DS3231-Control Remoto samsung Procesadores 2019-1 Equipo verde Guillermo Eduardo Luna Rozo Susana Buriticá Alvaro Javier Vargas David Cordoba Santiago Yepes Funciona correctamente, con 8 alarmas, se puede modificar la hora ccon encoder, y se configuran las alarmas con encoder y control.

Dependencies:   mbed QEI Debounced ds3231 TextLCD RTC-DS1307 Pulse1

Committer:
gelunar
Date:
Wed Aug 28 19:41:40 2019 +0000
Revision:
1:0075319c0341
Parent:
0:fd394f5c0449
Tarea Reloh DS3231-Control Remoto samsung Procesadores 2019-1 Equipo verde; Funciona correctamente, con 8 alarmas.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gelunar 1:0075319c0341 1 //Tarea Reloh DS3231-Control Remoto samsung Procesadores 2019-1 Equipo verde
gelunar 1:0075319c0341 2 //Guillermo Eduardo Luna Rozo
gelunar 1:0075319c0341 3 //Susana Buriticá
gelunar 1:0075319c0341 4 //Alvaro Javier Vargas
gelunar 1:0075319c0341 5 //David Cordoba
gelunar 1:0075319c0341 6 //Santiago Yepes
gelunar 1:0075319c0341 7 //Funciona correctamente, con 8 alarmas, se puede modificar la hora ccon encoder, y se configuran las alarmas con encoder y control
gelunar 1:0075319c0341 8
diavad 0:fd394f5c0449 9 #include "mbed.h"
gelunar 1:0075319c0341 10 #include "QEI.h"
diavad 0:fd394f5c0449 11 #include "TextLCD.h"
gelunar 1:0075319c0341 12 #include "DebouncedIn.h"
gelunar 1:0075319c0341 13 #include "string.h"
diavad 0:fd394f5c0449 14 #include "ds3231.h"
gelunar 1:0075319c0341 15 #include <Pulse1.h>
diavad 0:fd394f5c0449 16 #include "Rtc_Ds1307.h"
gelunar 1:0075319c0341 17
diavad 0:fd394f5c0449 18 #define ESC 0x1B
gelunar 1:0075319c0341 19
gelunar 1:0075319c0341 20
gelunar 1:0075319c0341 21 //Use X4 encoding.
gelunar 1:0075319c0341 22 //QEI wheel(p29, p30, NC, 624, QEI::X4_ENCODING);
gelunar 1:0075319c0341 23 //Use X2 encoding by default.
gelunar 1:0075319c0341 24 PulseInOut irda(PTD5);// en este puerto se pone el sensor infrarrojo
gelunar 1:0075319c0341 25 Serial pc(USBTX, USBRX);
gelunar 1:0075319c0341 26 QEI wheel (PTD7, PTD6, NC, 50);//Encoder
gelunar 1:0075319c0341 27 DebouncedIn bot1(PTC5);//Botón encoder
gelunar 1:0075319c0341 28 DebouncedIn boton(PTA17);//Botón
gelunar 1:0075319c0341 29 DebouncedIn boton2(PTA16);//Botón configurar alarma
gelunar 1:0075319c0341 30 TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5, TextLCD::LCD16x2); // rs, e, d4-d7
gelunar 1:0075319c0341 31 DigitalOut led1(PTC7);//Salidas
gelunar 1:0075319c0341 32 DigitalOut led2(PTC0);
gelunar 1:0075319c0341 33 DigitalOut led3(PTC3);
gelunar 1:0075319c0341 34 DigitalOut led(LED3);
gelunar 1:0075319c0341 35 DigitalOut ledd2(LED1);
gelunar 1:0075319c0341 36
gelunar 1:0075319c0341 37 //-----------parametros IRDA -------
gelunar 1:0075319c0341 38 int header =0; //tiempo de cabecera pulso abajo
gelunar 1:0075319c0341 39 const int head_H = 4900; //+20% medida con osciloscopio en microsegundos
gelunar 1:0075319c0341 40 const int head_L = 3500 ;//-20% medida con osciloscopio
gelunar 1:0075319c0341 41 int il=0, x=0;
gelunar 1:0075319c0341 42 const int T_alto=1694;//ponga su tiempo de la prueba
gelunar 1:0075319c0341 43 const int T_bajo=632;//ponga su tiempo de la prueba
gelunar 1:0075319c0341 44 const int num_bits = 32;//ponga su numero de bits
gelunar 1:0075319c0341 45 int num[num_bits];//cadena para almacenar todos los tiempos que conforman los bits de datos
gelunar 1:0075319c0341 46 char sel[num_bits];//cadena para almacenar la cadena codificada en binario
gelunar 1:0075319c0341 47 char uno[]="1110000011100000001000001101111"; //0,0,1,0,0,0,0,0,1,1,0,1,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,1,0,1,1,0
gelunar 1:0075319c0341 48 char dos[]="1110000011100000101000000101111";
gelunar 1:0075319c0341 49 char tres[]="1110000011100000011000001001111";
gelunar 1:0075319c0341 50 char cuatro[]="1110000011100000000100001110111";
gelunar 1:0075319c0341 51 char cinco[]="1110000011100000100100000110111";
gelunar 1:0075319c0341 52 char seis[]="1110000011100000010100001010111";
gelunar 1:0075319c0341 53 char siete[]="1110000011100000001100001100111";
gelunar 1:0075319c0341 54 char ocho[]="1110000011100000101100000100111";
gelunar 1:0075319c0341 55 char nueve[]="1110000011100000011100001000111";
gelunar 1:0075319c0341 56 char cero[]="1110000011100000100010000111011";
gelunar 1:0075319c0341 57
gelunar 1:0075319c0341 58 char ok[]="1110000011100000000101101110100"; //"00100000110111110000000011111110"; //0,0,1,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0
gelunar 1:0075319c0341 59 char izq[]="1110000011100000101001100101100";//"00100000110111110010001011011100
gelunar 1:0075319c0341 60 char der[]="1110000011100000010001101011100";
gelunar 1:0075319c0341 61 int dato; // tiempo de cada dato que se lee
gelunar 1:0075319c0341 62 int irdan(void);
gelunar 1:0075319c0341 63 int y=0;
gelunar 1:0075319c0341 64 int detectar(void);//funcion detecta irda
gelunar 1:0075319c0341 65 int Alarm_IRDA(void);//funcion valor irda
gelunar 1:0075319c0341 66 int ConfiReloj(void); //configurarrelogsinno
gelunar 1:0075319c0341 67
gelunar 1:0075319c0341 68 void get_user_input(char* message, uint8_t min, uint8_t max, uint32_t* member);
gelunar 1:0075319c0341 69 void get_user_input(char* message, uint8_t min, uint8_t max, bool* member);
gelunar 1:0075319c0341 70
gelunar 1:0075319c0341 71 int mode=0;
gelunar 1:0075319c0341 72 int numb=34;
gelunar 1:0075319c0341 73
gelunar 1:0075319c0341 74 //
gelunar 1:0075319c0341 75
gelunar 1:0075319c0341 76 int d;
gelunar 1:0075319c0341 77 int m;
gelunar 1:0075319c0341 78 int mes;
gelunar 1:0075319c0341 79 int an,h,min,sec,a;
gelunar 1:0075319c0341 80 int Conf=0;
gelunar 1:0075319c0341 81 int s=0; // 0: si y 1:no alarma ok
gelunar 1:0075319c0341 82 int f=0; // 0: si y 1:no otra alrama
gelunar 1:0075319c0341 83 int Lugar=1,Lugar2=2,Lugar3=3;
gelunar 1:0075319c0341 84 int pos=0,n=0; // Definen el punto en el cual va el programa
gelunar 1:0075319c0341 85 int i=0;
gelunar 1:0075319c0341 86 int j=1; //Cuenta las alarmas
gelunar 1:0075319c0341 87 int Select=1; //Alarma Seleccionada
gelunar 1:0075319c0341 88 int StarReadIR=0;
gelunar 1:0075319c0341 89 int visual=0; //0: Reloj y 1:Alarm
gelunar 1:0075319c0341 90 int alarma=0; //0: Desactivar y 1:Posponer
gelunar 1:0075319c0341 91 int Vec1[7];
gelunar 1:0075319c0341 92 int Vec2[7];
gelunar 1:0075319c0341 93 int Vec3[7];
gelunar 1:0075319c0341 94 int Vec4[7];
gelunar 1:0075319c0341 95 int Vec5[7];
gelunar 1:0075319c0341 96 int Vec6[7];
diavad 0:fd394f5c0449 97 Rtc_Ds1307 rtc(PTE0, PTE1);//SCL,SDA
diavad 0:fd394f5c0449 98 Rtc_Ds1307::Time_rtc tm = {};
gelunar 1:0075319c0341 99 time_t epoch_time;
gelunar 1:0075319c0341 100
gelunar 1:0075319c0341 101
gelunar 1:0075319c0341 102 int main()
gelunar 1:0075319c0341 103 {
gelunar 1:0075319c0341 104
gelunar 1:0075319c0341 105 Ds3231 rtc(PTE0, PTE1);
gelunar 1:0075319c0341 106 Rtc_Ds1307::Time_rtc tm = {};
gelunar 1:0075319c0341 107 time_t epoch_time;
gelunar 1:0075319c0341 108 ds3231_cntl_stat_t rtc_control_status = {0,0};
gelunar 1:0075319c0341 109 ds3231_time_t rtc_time={0,0,0,0,0};
gelunar 1:0075319c0341 110 ds3231_calendar_t rtc_calendar={0,0,0,0};
gelunar 1:0075319c0341 111 rtc.set_cntl_stat_reg(rtc_control_status);
gelunar 1:0075319c0341 112
gelunar 1:0075319c0341 113
gelunar 1:0075319c0341 114
gelunar 1:0075319c0341 115 loop1:
gelunar 1:0075319c0341 116 epoch_time = rtc.get_epoch();
gelunar 1:0075319c0341 117 rtc.get_time(&rtc_time);
gelunar 1:0075319c0341 118 rtc.get_calendar(&rtc_calendar);
gelunar 1:0075319c0341 119 j=1;
gelunar 1:0075319c0341 120 Conf=0;
gelunar 1:0075319c0341 121 s=0;
gelunar 1:0075319c0341 122 f=0;
gelunar 1:0075319c0341 123 Lugar=1;
gelunar 1:0075319c0341 124 Lugar2=2;
gelunar 1:0075319c0341 125 Lugar3=3;
gelunar 1:0075319c0341 126 pos=0;
gelunar 1:0075319c0341 127 i=0;
gelunar 1:0075319c0341 128 y=0;
gelunar 1:0075319c0341 129 lcd.cls();
gelunar 1:0075319c0341 130 lcd.locate(14,0);
gelunar 1:0075319c0341 131 lcd.printf("-A");
gelunar 1:0075319c0341 132 lcd.locate(2,0);
gelunar 1:0075319c0341 133 lcd.printf("\nFecha:%02d/%02d/%02d",rtc_calendar.date,rtc_calendar.month,rtc_calendar.year);
gelunar 1:0075319c0341 134 m=wheel.getPulses();
gelunar 1:0075319c0341 135 //Reloj corriendo y comparamdo con alarmas//
gelunar 1:0075319c0341 136 while(!bot1.falling() && !boton.falling() && !boton2.falling()){
gelunar 1:0075319c0341 137 rtc.get_time(&rtc_time);
gelunar 1:0075319c0341 138 lcd.locate(0,1);
gelunar 1:0075319c0341 139 lcd.printf("\nHora:%02d:%02d:%02d", rtc_time.hours,rtc_time.minutes,rtc_time.seconds );
gelunar 1:0075319c0341 140 if(Vec1[1]==rtc_calendar.date && Vec1[2]==rtc_calendar.month && Vec1[3]==rtc_calendar.year && Vec1[4]==rtc_time.hours && Vec1[5]==rtc_time.minutes && Vec1[6]==rtc_time.seconds){
gelunar 1:0075319c0341 141 led1=1;}
gelunar 1:0075319c0341 142 if(Vec2[1]==rtc_calendar.date && Vec2[2]==rtc_calendar.month && Vec2[3]==rtc_calendar.year && Vec2[4]==rtc_time.hours && Vec2[5]==rtc_time.minutes && Vec2[6]==rtc_time.seconds){
gelunar 1:0075319c0341 143 led2=1;}
gelunar 1:0075319c0341 144 if(Vec3[1]==rtc_calendar.date && Vec3[2]==rtc_calendar.month && Vec3[3]==rtc_calendar.year && Vec3[4]==rtc_time.hours && Vec3[5]==rtc_time.minutes && Vec3[6]==rtc_time.seconds){
gelunar 1:0075319c0341 145 led3=1;}
gelunar 1:0075319c0341 146 if(Vec4[1]==rtc_calendar.date && Vec4[2]==rtc_calendar.month && Vec4[3]==rtc_calendar.year && Vec4[4]==rtc_time.hours && Vec4[5]==rtc_time.minutes && Vec4[6]==rtc_time.seconds){
gelunar 1:0075319c0341 147 led1=0;}
gelunar 1:0075319c0341 148 if(Vec5[1]==rtc_calendar.date && Vec5[2]==rtc_calendar.month && Vec5[3]==rtc_calendar.year && Vec5[4]==rtc_time.hours && Vec5[5]==rtc_time.minutes && Vec5[6]==rtc_time.seconds){
gelunar 1:0075319c0341 149 led2=0;}
gelunar 1:0075319c0341 150 if(Vec6[1]==rtc_calendar.date && Vec6[2]==rtc_calendar.month && Vec6[3]==rtc_calendar.year && Vec6[4]==rtc_time.hours && Vec6[5]==rtc_time.minutes && Vec6[6]==rtc_time.seconds){
gelunar 1:0075319c0341 151 led3=0;}
gelunar 1:0075319c0341 152 }
gelunar 1:0075319c0341 153
gelunar 1:0075319c0341 154 while(1)
gelunar 1:0075319c0341 155 {
gelunar 1:0075319c0341 156
gelunar 1:0075319c0341 157 if (bot1.falling()){ //Para que trabaje con encoder
gelunar 1:0075319c0341 158 Lugar++;
gelunar 1:0075319c0341 159 }
gelunar 1:0075319c0341 160 if(boton.falling()){
gelunar 1:0075319c0341 161 Lugar2++;
gelunar 1:0075319c0341 162 }
gelunar 1:0075319c0341 163 if(boton2.falling()){
gelunar 1:0075319c0341 164 Lugar3++;
gelunar 1:0075319c0341 165 }
gelunar 1:0075319c0341 166 switch (Lugar)//Encoder
gelunar 1:0075319c0341 167 {
gelunar 1:0075319c0341 168 case 2:
gelunar 1:0075319c0341 169 switch(i)
gelunar 1:0075319c0341 170 {
gelunar 1:0075319c0341 171 case 0:
gelunar 1:0075319c0341 172 if(Conf==0){
gelunar 1:0075319c0341 173 lcd.cls();
gelunar 1:0075319c0341 174 lcd.locate(0,0);
gelunar 1:0075319c0341 175 lcd.printf("Alarma: ");
gelunar 1:0075319c0341 176 i++;
gelunar 1:0075319c0341 177 }
gelunar 1:0075319c0341 178 break;
gelunar 1:0075319c0341 179 case 1:
gelunar 1:0075319c0341 180 m=0;
gelunar 1:0075319c0341 181 m=wheel.getPulses();
gelunar 1:0075319c0341 182 if (m!=0){
gelunar 1:0075319c0341 183 a=m;
gelunar 1:0075319c0341 184 if(a>9){
gelunar 1:0075319c0341 185 a=8;
gelunar 1:0075319c0341 186 }
gelunar 1:0075319c0341 187 if (a<1){
gelunar 1:0075319c0341 188 a=1;
gelunar 1:0075319c0341 189 }
gelunar 1:0075319c0341 190 }
gelunar 1:0075319c0341 191 lcd.locate(10,0);
gelunar 1:0075319c0341 192 lcd.printf("%02d ",a);
gelunar 1:0075319c0341 193 if(bot1.falling()){
gelunar 1:0075319c0341 194 loop2:
gelunar 1:0075319c0341 195 lcd.cls();
gelunar 1:0075319c0341 196 lcd.printf("Config. Alarmas ");
gelunar 1:0075319c0341 197 wait(1);
diavad 0:fd394f5c0449 198 lcd.cls();
gelunar 1:0075319c0341 199 i=2;
gelunar 1:0075319c0341 200 s=0;
gelunar 1:0075319c0341 201 f=0;
gelunar 1:0075319c0341 202 Lugar=2;
gelunar 1:0075319c0341 203 pos=0;
gelunar 1:0075319c0341 204 lcd.locate(0,0);
gelunar 1:0075319c0341 205 lcd.printf("Dia: ");
gelunar 1:0075319c0341 206 m=0;
gelunar 1:0075319c0341 207 wheel.reset();
diavad 0:fd394f5c0449 208 }
gelunar 1:0075319c0341 209 break;
gelunar 1:0075319c0341 210 case 2: // Dia
gelunar 1:0075319c0341 211 m=0;
gelunar 1:0075319c0341 212 m=wheel.getPulses();
gelunar 1:0075319c0341 213 if (m!=0)
gelunar 1:0075319c0341 214 {
gelunar 1:0075319c0341 215 d=m;
gelunar 1:0075319c0341 216 if(d>31)
gelunar 1:0075319c0341 217 {
gelunar 1:0075319c0341 218 d=31;
gelunar 1:0075319c0341 219 }
gelunar 1:0075319c0341 220 if(d<1)
gelunar 1:0075319c0341 221 {
gelunar 1:0075319c0341 222 d=1;
gelunar 1:0075319c0341 223 }
gelunar 1:0075319c0341 224
gelunar 1:0075319c0341 225
gelunar 1:0075319c0341 226 }
gelunar 1:0075319c0341 227 lcd.locate(5,0);
gelunar 1:0075319c0341 228 lcd.printf("%02d ",d);
gelunar 1:0075319c0341 229
gelunar 1:0075319c0341 230 if (bot1.falling())
gelunar 1:0075319c0341 231 {
gelunar 1:0075319c0341 232 i++;
gelunar 1:0075319c0341 233 m=0;
gelunar 1:0075319c0341 234 lcd.cls();
gelunar 1:0075319c0341 235 lcd.locate(0,0);
gelunar 1:0075319c0341 236 lcd.printf("Mes: ");
gelunar 1:0075319c0341 237
gelunar 1:0075319c0341 238 wheel.reset();
gelunar 1:0075319c0341 239
gelunar 1:0075319c0341 240 }
gelunar 1:0075319c0341 241 break;
gelunar 1:0075319c0341 242
gelunar 1:0075319c0341 243 case 3: // Mes
gelunar 1:0075319c0341 244 m=0;
gelunar 1:0075319c0341 245 m=wheel.getPulses();
gelunar 1:0075319c0341 246 if (m!=0)
gelunar 1:0075319c0341 247 {
gelunar 1:0075319c0341 248 mes=m;
gelunar 1:0075319c0341 249 if(mes>12)
gelunar 1:0075319c0341 250 {
gelunar 1:0075319c0341 251 mes=12;
gelunar 1:0075319c0341 252 }
gelunar 1:0075319c0341 253 if(mes<1)
gelunar 1:0075319c0341 254 {
gelunar 1:0075319c0341 255 mes=1;
gelunar 1:0075319c0341 256 }
gelunar 1:0075319c0341 257
gelunar 1:0075319c0341 258
gelunar 1:0075319c0341 259 }
gelunar 1:0075319c0341 260 lcd.locate(7,0);
gelunar 1:0075319c0341 261 lcd.printf("%02d",mes);
gelunar 1:0075319c0341 262
gelunar 1:0075319c0341 263 if (bot1.falling())
gelunar 1:0075319c0341 264 {
gelunar 1:0075319c0341 265 i++;
gelunar 1:0075319c0341 266 m=0;
gelunar 1:0075319c0341 267 lcd.cls();
gelunar 1:0075319c0341 268 lcd.locate(0,0);
gelunar 1:0075319c0341 269 lcd.printf("Anno: ");
gelunar 1:0075319c0341 270 wheel.reset();
gelunar 1:0075319c0341 271 }
gelunar 1:0075319c0341 272
gelunar 1:0075319c0341 273 break;
gelunar 1:0075319c0341 274
gelunar 1:0075319c0341 275 case 4: //Año
gelunar 1:0075319c0341 276 m=wheel.getPulses();
gelunar 1:0075319c0341 277 if (m!=0)
gelunar 1:0075319c0341 278 {
gelunar 1:0075319c0341 279 an=m;
gelunar 1:0075319c0341 280
gelunar 1:0075319c0341 281 if(an<0)
gelunar 1:0075319c0341 282 {
gelunar 1:0075319c0341 283 an=0;
gelunar 1:0075319c0341 284 }
gelunar 1:0075319c0341 285 if(an>99){
gelunar 1:0075319c0341 286 an=99;
gelunar 1:0075319c0341 287 }
gelunar 1:0075319c0341 288
gelunar 1:0075319c0341 289
gelunar 1:0075319c0341 290 }
gelunar 1:0075319c0341 291 lcd.locate(6,0);
gelunar 1:0075319c0341 292 lcd.printf("%02d",an);
gelunar 1:0075319c0341 293
gelunar 1:0075319c0341 294 if (bot1.falling())
gelunar 1:0075319c0341 295 {
gelunar 1:0075319c0341 296 i++;
gelunar 1:0075319c0341 297 m=0;
gelunar 1:0075319c0341 298 lcd.cls();
gelunar 1:0075319c0341 299 lcd.locate(0,0);
gelunar 1:0075319c0341 300 lcd.printf("Config. Hora");
gelunar 1:0075319c0341 301 wait(1);
gelunar 1:0075319c0341 302 lcd.cls();
gelunar 1:0075319c0341 303 lcd.printf("Hora: ");
gelunar 1:0075319c0341 304 wheel.reset();
gelunar 1:0075319c0341 305
gelunar 1:0075319c0341 306 }
gelunar 1:0075319c0341 307
gelunar 1:0075319c0341 308 break;
gelunar 1:0075319c0341 309
gelunar 1:0075319c0341 310 case 5: //HORA
gelunar 1:0075319c0341 311
gelunar 1:0075319c0341 312
gelunar 1:0075319c0341 313 m=0;
gelunar 1:0075319c0341 314 m=wheel.getPulses();
gelunar 1:0075319c0341 315 if (m!=0)
gelunar 1:0075319c0341 316 {
gelunar 1:0075319c0341 317 h= m;
gelunar 1:0075319c0341 318 if(h>23)
gelunar 1:0075319c0341 319 {
gelunar 1:0075319c0341 320 h=23;
gelunar 1:0075319c0341 321 }
gelunar 1:0075319c0341 322 if(h<0)
gelunar 1:0075319c0341 323 {
gelunar 1:0075319c0341 324 h=0;
gelunar 1:0075319c0341 325 }
gelunar 1:0075319c0341 326
gelunar 1:0075319c0341 327 }
gelunar 1:0075319c0341 328 lcd.locate(6,0);
gelunar 1:0075319c0341 329 lcd.printf("%02d",h);
gelunar 1:0075319c0341 330
gelunar 1:0075319c0341 331 if (bot1.falling())
gelunar 1:0075319c0341 332 {
gelunar 1:0075319c0341 333 i++;
gelunar 1:0075319c0341 334 m=0;
gelunar 1:0075319c0341 335 lcd.cls();
gelunar 1:0075319c0341 336 lcd.locate(0,0);
gelunar 1:0075319c0341 337 lcd.printf("Minuto: ");
gelunar 1:0075319c0341 338 wheel.reset();
gelunar 1:0075319c0341 339 }
gelunar 1:0075319c0341 340
gelunar 1:0075319c0341 341 break;
gelunar 1:0075319c0341 342
gelunar 1:0075319c0341 343 case 6: //MINUTOS
gelunar 1:0075319c0341 344 m=0;
gelunar 1:0075319c0341 345 m=wheel.getPulses();
gelunar 1:0075319c0341 346 if (m!=0)
gelunar 1:0075319c0341 347 {
gelunar 1:0075319c0341 348 min=m;
gelunar 1:0075319c0341 349 if(min>59)
gelunar 1:0075319c0341 350 {
gelunar 1:0075319c0341 351 min=59;
gelunar 1:0075319c0341 352 }
gelunar 1:0075319c0341 353 if(min<0)
gelunar 1:0075319c0341 354 {
gelunar 1:0075319c0341 355 min=0;
gelunar 1:0075319c0341 356 }
gelunar 1:0075319c0341 357
gelunar 1:0075319c0341 358 }
gelunar 1:0075319c0341 359 lcd.locate(8,0);
gelunar 1:0075319c0341 360 lcd.printf("%02d",min);
gelunar 1:0075319c0341 361
gelunar 1:0075319c0341 362 if (bot1.falling())
gelunar 1:0075319c0341 363 {
gelunar 1:0075319c0341 364 i++;
gelunar 1:0075319c0341 365
gelunar 1:0075319c0341 366 lcd.cls();
gelunar 1:0075319c0341 367 lcd.locate(0,0);
gelunar 1:0075319c0341 368 lcd.printf("Segundo: ");
gelunar 1:0075319c0341 369 wheel.reset();
gelunar 1:0075319c0341 370 }
gelunar 1:0075319c0341 371
gelunar 1:0075319c0341 372 break;
gelunar 1:0075319c0341 373
gelunar 1:0075319c0341 374
gelunar 1:0075319c0341 375 case 7: //SEGUNDOS
gelunar 1:0075319c0341 376 m=0;
gelunar 1:0075319c0341 377 m=wheel.getPulses();
gelunar 1:0075319c0341 378 if (m!=0)
gelunar 1:0075319c0341 379 {
gelunar 1:0075319c0341 380 sec=m;
gelunar 1:0075319c0341 381 if(sec>59)
gelunar 1:0075319c0341 382 {
gelunar 1:0075319c0341 383 sec=59;
gelunar 1:0075319c0341 384 }
gelunar 1:0075319c0341 385 if(sec<0)
gelunar 1:0075319c0341 386 {
gelunar 1:0075319c0341 387 sec=0;
gelunar 1:0075319c0341 388 }
gelunar 1:0075319c0341 389
gelunar 1:0075319c0341 390 }
gelunar 1:0075319c0341 391
gelunar 1:0075319c0341 392 lcd.locate(8,0);
gelunar 1:0075319c0341 393 lcd.printf("%02d",sec);
gelunar 1:0075319c0341 394 if(bot1.falling()){
gelunar 1:0075319c0341 395
gelunar 1:0075319c0341 396 i++;
gelunar 1:0075319c0341 397
gelunar 1:0075319c0341 398 lcd.cls();
gelunar 1:0075319c0341 399 wheel.reset();
gelunar 1:0075319c0341 400
gelunar 1:0075319c0341 401 }
gelunar 1:0075319c0341 402 break;
gelunar 1:0075319c0341 403 case 8:
gelunar 1:0075319c0341 404 m=0;
gelunar 1:0075319c0341 405 lcd.locate(0,1);
gelunar 1:0075319c0341 406 lcd.printf("\nAlarm:%02d:%02d:%02d",h,min,sec);
gelunar 1:0075319c0341 407 lcd.locate(2,0);
gelunar 1:0075319c0341 408 lcd.printf("\nFecha:%02d/%02d/%02d",d,mes,an);
gelunar 1:0075319c0341 409 wait(2);
gelunar 1:0075319c0341 410 lcd.cls();
gelunar 1:0075319c0341 411 lcd.locate(0,1);
gelunar 1:0075319c0341 412 lcd.printf("Alarma OK ?");
gelunar 1:0075319c0341 413 lcd.locate(2,0);
gelunar 1:0075319c0341 414 lcd.printf("--Si --No");
gelunar 1:0075319c0341 415 i++;
gelunar 1:0075319c0341 416 wheel.reset();
gelunar 1:0075319c0341 417 break;
gelunar 1:0075319c0341 418
gelunar 1:0075319c0341 419 case 9:
gelunar 1:0075319c0341 420
gelunar 1:0075319c0341 421 m=wheel.getPulses(); // m son los datos del encoder
gelunar 1:0075319c0341 422 if(m!=0 && s==0){
gelunar 1:0075319c0341 423 s=1;
gelunar 1:0075319c0341 424 wheel.reset();
gelunar 1:0075319c0341 425 m=0;
diavad 0:fd394f5c0449 426 }
gelunar 1:0075319c0341 427
gelunar 1:0075319c0341 428 if(m!=0 && s==1){
gelunar 1:0075319c0341 429 s=0;
gelunar 1:0075319c0341 430 wheel.reset();
gelunar 1:0075319c0341 431 m=0;
gelunar 1:0075319c0341 432 }
gelunar 1:0075319c0341 433
gelunar 1:0075319c0341 434 if(s==0){
gelunar 1:0075319c0341 435
gelunar 1:0075319c0341 436 lcd.locate(11,0);
gelunar 1:0075319c0341 437 lcd.printf("-");
gelunar 1:0075319c0341 438 lcd.locate(1,0);
gelunar 1:0075319c0341 439 lcd.printf(">");
gelunar 1:0075319c0341 440 lcd.locate(0,1);
gelunar 1:0075319c0341 441 wait(0.1);
gelunar 1:0075319c0341 442 }
gelunar 1:0075319c0341 443 if(s==1){
gelunar 1:0075319c0341 444
gelunar 1:0075319c0341 445 lcd.locate(1,0);
gelunar 1:0075319c0341 446 lcd.printf("-");
gelunar 1:0075319c0341 447 lcd.locate(11,0);
gelunar 1:0075319c0341 448 lcd.printf(">");
gelunar 1:0075319c0341 449 lcd.locate(0,1);
gelunar 1:0075319c0341 450 wait(0.1);
gelunar 1:0075319c0341 451 }
gelunar 1:0075319c0341 452
gelunar 1:0075319c0341 453 if(s==1){
gelunar 1:0075319c0341 454
gelunar 1:0075319c0341 455 lcd.locate(1,0);
gelunar 1:0075319c0341 456 lcd.printf("-");
gelunar 1:0075319c0341 457 lcd.locate(11,0);
gelunar 1:0075319c0341 458 lcd.printf(">");
gelunar 1:0075319c0341 459 lcd.locate(0,1);
gelunar 1:0075319c0341 460 wait(0.1);
gelunar 1:0075319c0341 461 }
gelunar 1:0075319c0341 462
gelunar 1:0075319c0341 463 if (bot1.falling()){ //si se pulsa boton encoder
gelunar 1:0075319c0341 464 pos++;
gelunar 1:0075319c0341 465 m=0;
gelunar 1:0075319c0341 466 }
gelunar 1:0075319c0341 467
gelunar 1:0075319c0341 468 break;
gelunar 1:0075319c0341 469
gelunar 1:0075319c0341 470
gelunar 1:0075319c0341 471
gelunar 1:0075319c0341 472 }
gelunar 1:0075319c0341 473 switch (pos)
gelunar 1:0075319c0341 474 {
gelunar 1:0075319c0341 475 case 1:
gelunar 1:0075319c0341 476 if(s==0){
gelunar 1:0075319c0341 477 lcd.cls();
gelunar 1:0075319c0341 478 lcd.locate(0,1);
gelunar 1:0075319c0341 479 if(a==1){
gelunar 1:0075319c0341 480 Vec1[1]=d;
gelunar 1:0075319c0341 481 Vec1[2]=mes;
gelunar 1:0075319c0341 482 Vec1[3]=an;
gelunar 1:0075319c0341 483 Vec1[4]=h;
gelunar 1:0075319c0341 484 Vec1[5]=min;
gelunar 1:0075319c0341 485 Vec1[6]=sec;
gelunar 1:0075319c0341 486 }
gelunar 1:0075319c0341 487 if(a==2){
gelunar 1:0075319c0341 488 Vec2[1]=d;
gelunar 1:0075319c0341 489 Vec2[2]=mes;
gelunar 1:0075319c0341 490 Vec2[3]=an;
gelunar 1:0075319c0341 491 Vec2[4]=h;
gelunar 1:0075319c0341 492 Vec2[5]=min;
gelunar 1:0075319c0341 493 Vec2[6]=sec;
gelunar 1:0075319c0341 494 }
gelunar 1:0075319c0341 495 if(a==3){
gelunar 1:0075319c0341 496 Vec3[1]=d;
gelunar 1:0075319c0341 497 Vec3[2]=mes;
gelunar 1:0075319c0341 498 Vec3[3]=an;
gelunar 1:0075319c0341 499 Vec3[4]=h;
gelunar 1:0075319c0341 500 Vec3[5]=min;
gelunar 1:0075319c0341 501 Vec3[6]=sec;
gelunar 1:0075319c0341 502 }
gelunar 1:0075319c0341 503 if(a==4){
gelunar 1:0075319c0341 504 Vec4[1]=d;
gelunar 1:0075319c0341 505 Vec4[2]=mes;
gelunar 1:0075319c0341 506 Vec4[3]=an;
gelunar 1:0075319c0341 507 Vec4[4]=h;
gelunar 1:0075319c0341 508 Vec4[5]=min;
gelunar 1:0075319c0341 509 Vec4[6]=sec;
gelunar 1:0075319c0341 510 }
gelunar 1:0075319c0341 511 if(a==5){
gelunar 1:0075319c0341 512 Vec5[1]=d;
gelunar 1:0075319c0341 513 Vec5[2]=mes;
gelunar 1:0075319c0341 514 Vec5[3]=an;
gelunar 1:0075319c0341 515 Vec5[4]=h;
gelunar 1:0075319c0341 516 Vec5[5]=min;
gelunar 1:0075319c0341 517 Vec5[6]=sec;
gelunar 1:0075319c0341 518 }
gelunar 1:0075319c0341 519 if(a==6){
gelunar 1:0075319c0341 520 Vec6[1]=d;
gelunar 1:0075319c0341 521 Vec6[2]=mes;
gelunar 1:0075319c0341 522 Vec6[3]=an;
gelunar 1:0075319c0341 523 Vec6[4]=h;
gelunar 1:0075319c0341 524 Vec6[5]=min;
gelunar 1:0075319c0341 525 Vec6[6]=sec;
gelunar 1:0075319c0341 526 }
gelunar 1:0075319c0341 527 lcd.printf("Otra alarma? %0.2d",Vec1[6]);
gelunar 1:0075319c0341 528 lcd.locate(2,0);
gelunar 1:0075319c0341 529 lcd.printf("--Si --No");
gelunar 1:0075319c0341 530 wheel.reset();
gelunar 1:0075319c0341 531 pos++;
gelunar 1:0075319c0341 532 }
gelunar 1:0075319c0341 533
gelunar 1:0075319c0341 534 if(s==1){
gelunar 1:0075319c0341 535 lcd.cls();
gelunar 1:0075319c0341 536 goto loop2;
gelunar 1:0075319c0341 537 }
gelunar 1:0075319c0341 538
gelunar 1:0075319c0341 539 break;
gelunar 1:0075319c0341 540 case 2:
gelunar 1:0075319c0341 541 m=wheel.getPulses(); // m son los datos del encoder
gelunar 1:0075319c0341 542 if(m!=0 && f==0){
gelunar 1:0075319c0341 543 f=1;
gelunar 1:0075319c0341 544 wheel.reset();
gelunar 1:0075319c0341 545 m=0;
gelunar 1:0075319c0341 546 }
gelunar 1:0075319c0341 547
gelunar 1:0075319c0341 548 if(m!=0 && f==1){
gelunar 1:0075319c0341 549 f=0;
gelunar 1:0075319c0341 550 wheel.reset();
gelunar 1:0075319c0341 551 m=0;
gelunar 1:0075319c0341 552 }
gelunar 1:0075319c0341 553
gelunar 1:0075319c0341 554 if(f==0){
gelunar 1:0075319c0341 555
gelunar 1:0075319c0341 556 lcd.locate(11,0);
gelunar 1:0075319c0341 557 lcd.printf("-");
gelunar 1:0075319c0341 558 lcd.locate(1,0);
gelunar 1:0075319c0341 559 lcd.printf(">");
gelunar 1:0075319c0341 560 lcd.locate(0,1);
gelunar 1:0075319c0341 561 wait(0.1);
gelunar 1:0075319c0341 562 }
gelunar 1:0075319c0341 563 if(f==1){
gelunar 1:0075319c0341 564
gelunar 1:0075319c0341 565 lcd.locate(1,0);
gelunar 1:0075319c0341 566 lcd.printf("-");
gelunar 1:0075319c0341 567 lcd.locate(11,0);
gelunar 1:0075319c0341 568 lcd.printf(">");
gelunar 1:0075319c0341 569 lcd.locate(0,1);
gelunar 1:0075319c0341 570 wait(0.1);
gelunar 1:0075319c0341 571 }
gelunar 1:0075319c0341 572
gelunar 1:0075319c0341 573 if(f==1){
gelunar 1:0075319c0341 574
gelunar 1:0075319c0341 575 lcd.locate(1,0);
gelunar 1:0075319c0341 576 lcd.printf("-");
gelunar 1:0075319c0341 577 lcd.locate(11,0);
gelunar 1:0075319c0341 578 lcd.printf(">");
gelunar 1:0075319c0341 579 lcd.locate(0,1);
gelunar 1:0075319c0341 580 wait(0.1);
gelunar 1:0075319c0341 581 }
diavad 0:fd394f5c0449 582
gelunar 1:0075319c0341 583 if (bot1.falling()){ //si se pulsa boton encoder
gelunar 1:0075319c0341 584 wheel.reset();
gelunar 1:0075319c0341 585 lcd.cls();
gelunar 1:0075319c0341 586 pos++;
gelunar 1:0075319c0341 587
gelunar 1:0075319c0341 588
gelunar 1:0075319c0341 589
gelunar 1:0075319c0341 590 }
gelunar 1:0075319c0341 591 break;
gelunar 1:0075319c0341 592 case 3:
gelunar 1:0075319c0341 593 if(f==0){
gelunar 1:0075319c0341 594 wheel.reset();
gelunar 1:0075319c0341 595 lcd.cls();
gelunar 1:0075319c0341 596 goto loop1;
gelunar 1:0075319c0341 597 }
gelunar 1:0075319c0341 598 if(f==1){
gelunar 1:0075319c0341 599 wheel.reset();
gelunar 1:0075319c0341 600 lcd.cls();
gelunar 1:0075319c0341 601 goto loop1; //Va al reloj
gelunar 1:0075319c0341 602 }
gelunar 1:0075319c0341 603 break;
gelunar 1:0075319c0341 604
gelunar 1:0075319c0341 605 }
gelunar 1:0075319c0341 606
gelunar 1:0075319c0341 607 }
diavad 0:fd394f5c0449 608
gelunar 1:0075319c0341 609 switch (Lugar2)//Control
gelunar 1:0075319c0341 610 {
gelunar 1:0075319c0341 611 case 3:
gelunar 1:0075319c0341 612
gelunar 1:0075319c0341 613 switch(i)
gelunar 1:0075319c0341 614 {
gelunar 1:0075319c0341 615
gelunar 1:0075319c0341 616 case 0:
gelunar 1:0075319c0341 617 if(Conf==0){
gelunar 1:0075319c0341 618 loop3:
gelunar 1:0075319c0341 619 lcd.cls();
gelunar 1:0075319c0341 620 lcd.locate(0,0);
gelunar 1:0075319c0341 621 lcd.printf("Alarma: ");
gelunar 1:0075319c0341 622 i++;
gelunar 1:0075319c0341 623 Conf++;
gelunar 1:0075319c0341 624 m=0;
gelunar 1:0075319c0341 625 }
gelunar 1:0075319c0341 626
gelunar 1:0075319c0341 627 case 1:
gelunar 1:0075319c0341 628 if (Conf==1){
gelunar 1:0075319c0341 629
gelunar 1:0075319c0341 630 m=Alarm_IRDA();
gelunar 1:0075319c0341 631 if(m!=0){
gelunar 1:0075319c0341 632 a=m;
gelunar 1:0075319c0341 633 if(a>8){
gelunar 1:0075319c0341 634 a=8;
gelunar 1:0075319c0341 635 }
gelunar 1:0075319c0341 636 if (a<1){
gelunar 1:0075319c0341 637 a=1;
gelunar 1:0075319c0341 638 }
gelunar 1:0075319c0341 639 }
gelunar 1:0075319c0341 640 lcd.locate(10,0);
gelunar 1:0075319c0341 641 pc.printf("Alarma: %02d",a);
gelunar 1:0075319c0341 642 lcd.printf("%02d",a);
gelunar 1:0075319c0341 643
gelunar 1:0075319c0341 644 loop5:
gelunar 1:0075319c0341 645 if(Alarm_IRDA()==-8){
gelunar 1:0075319c0341 646 lcd.cls();
gelunar 1:0075319c0341 647 lcd.printf("Config. Alarmas ");
gelunar 1:0075319c0341 648 wait(1);
gelunar 1:0075319c0341 649 lcd.cls();
gelunar 1:0075319c0341 650 i=2;
gelunar 1:0075319c0341 651 s=0;
gelunar 1:0075319c0341 652 f=0;
gelunar 1:0075319c0341 653 Lugar=2;
gelunar 1:0075319c0341 654 pos=0;
gelunar 1:0075319c0341 655 lcd.locate(0,0);
gelunar 1:0075319c0341 656 lcd.printf("Dia: ");
gelunar 1:0075319c0341 657 m=0;
gelunar 1:0075319c0341 658 }
gelunar 1:0075319c0341 659 }
gelunar 1:0075319c0341 660
gelunar 1:0075319c0341 661 case 2: // Dia
gelunar 1:0075319c0341 662 m=0;
gelunar 1:0075319c0341 663 m=Alarm_IRDA();
gelunar 1:0075319c0341 664 if (m!=0)
gelunar 1:0075319c0341 665 {
gelunar 1:0075319c0341 666 d=m;
gelunar 1:0075319c0341 667 if(d>31)
gelunar 1:0075319c0341 668 {
gelunar 1:0075319c0341 669 d=31;
gelunar 1:0075319c0341 670 }
gelunar 1:0075319c0341 671 if(d<1)
gelunar 1:0075319c0341 672 {
gelunar 1:0075319c0341 673 d=1;
gelunar 1:0075319c0341 674 }
gelunar 1:0075319c0341 675
gelunar 1:0075319c0341 676
gelunar 1:0075319c0341 677 }
gelunar 1:0075319c0341 678 lcd.locate(5,0);
gelunar 1:0075319c0341 679 lcd.printf("%02d ",d);
gelunar 1:0075319c0341 680
gelunar 1:0075319c0341 681 if (Alarm_IRDA()==-8)
gelunar 1:0075319c0341 682 {
gelunar 1:0075319c0341 683 i++;
gelunar 1:0075319c0341 684 m=0;
gelunar 1:0075319c0341 685 lcd.cls();
gelunar 1:0075319c0341 686 lcd.locate(0,0);
gelunar 1:0075319c0341 687 lcd.printf("Mes: ");
gelunar 1:0075319c0341 688
gelunar 1:0075319c0341 689
gelunar 1:0075319c0341 690
gelunar 1:0075319c0341 691 }
gelunar 1:0075319c0341 692
gelunar 1:0075319c0341 693
gelunar 1:0075319c0341 694 case 3: // Mes
gelunar 1:0075319c0341 695 m=0;
gelunar 1:0075319c0341 696 m=Alarm_IRDA();
gelunar 1:0075319c0341 697 if (m!=0)
gelunar 1:0075319c0341 698 {
gelunar 1:0075319c0341 699 mes=m;
gelunar 1:0075319c0341 700 if(mes>12)
gelunar 1:0075319c0341 701 {
gelunar 1:0075319c0341 702 mes=12;
gelunar 1:0075319c0341 703 }
gelunar 1:0075319c0341 704 if(mes<1)
gelunar 1:0075319c0341 705 {
gelunar 1:0075319c0341 706 mes=1;
gelunar 1:0075319c0341 707 }
gelunar 1:0075319c0341 708
gelunar 1:0075319c0341 709
gelunar 1:0075319c0341 710 }
gelunar 1:0075319c0341 711 lcd.locate(7,0);
gelunar 1:0075319c0341 712 lcd.printf("%02d",mes);
gelunar 1:0075319c0341 713
gelunar 1:0075319c0341 714 if (Alarm_IRDA()==-8)
gelunar 1:0075319c0341 715 {
gelunar 1:0075319c0341 716 i++;
gelunar 1:0075319c0341 717 m=0;
gelunar 1:0075319c0341 718 lcd.cls();
gelunar 1:0075319c0341 719 lcd.locate(0,0);
gelunar 1:0075319c0341 720 lcd.printf("Anno: ");
gelunar 1:0075319c0341 721
gelunar 1:0075319c0341 722 }
gelunar 1:0075319c0341 723
gelunar 1:0075319c0341 724
gelunar 1:0075319c0341 725
gelunar 1:0075319c0341 726 case 4: //Año
gelunar 1:0075319c0341 727 m=Alarm_IRDA();
gelunar 1:0075319c0341 728 if (m!=0)
gelunar 1:0075319c0341 729 {
gelunar 1:0075319c0341 730 an=m;
gelunar 1:0075319c0341 731
gelunar 1:0075319c0341 732 if(an<0)
gelunar 1:0075319c0341 733 {
gelunar 1:0075319c0341 734 an=0;
gelunar 1:0075319c0341 735 }
gelunar 1:0075319c0341 736 if(an>99){
gelunar 1:0075319c0341 737 an=99;
gelunar 1:0075319c0341 738 }
gelunar 1:0075319c0341 739
gelunar 1:0075319c0341 740
gelunar 1:0075319c0341 741 }
gelunar 1:0075319c0341 742 lcd.locate(6,0);
gelunar 1:0075319c0341 743 lcd.printf("%02d",an);
gelunar 1:0075319c0341 744
gelunar 1:0075319c0341 745 if (Alarm_IRDA()==-8)
gelunar 1:0075319c0341 746 {
gelunar 1:0075319c0341 747 i++;
gelunar 1:0075319c0341 748 m=0;
gelunar 1:0075319c0341 749 lcd.cls();
gelunar 1:0075319c0341 750 lcd.locate(0,0);
gelunar 1:0075319c0341 751 lcd.printf("Config. Hora");
gelunar 1:0075319c0341 752 wait(1);
gelunar 1:0075319c0341 753 lcd.cls();
gelunar 1:0075319c0341 754 lcd.printf("Hora: ");
gelunar 1:0075319c0341 755
gelunar 1:0075319c0341 756
gelunar 1:0075319c0341 757 }
gelunar 1:0075319c0341 758
gelunar 1:0075319c0341 759
gelunar 1:0075319c0341 760
gelunar 1:0075319c0341 761 case 5: //HORA
gelunar 1:0075319c0341 762
diavad 0:fd394f5c0449 763
gelunar 1:0075319c0341 764 m=0;
gelunar 1:0075319c0341 765 m=Alarm_IRDA();
gelunar 1:0075319c0341 766 if (m!=0)
gelunar 1:0075319c0341 767 {
gelunar 1:0075319c0341 768 h= m;
gelunar 1:0075319c0341 769 if(h>23)
gelunar 1:0075319c0341 770 {
gelunar 1:0075319c0341 771 h=23;
gelunar 1:0075319c0341 772 }
gelunar 1:0075319c0341 773 if(h<0)
gelunar 1:0075319c0341 774 {
gelunar 1:0075319c0341 775 h=0;
gelunar 1:0075319c0341 776 }
gelunar 1:0075319c0341 777
gelunar 1:0075319c0341 778 }
gelunar 1:0075319c0341 779 lcd.locate(6,0);
gelunar 1:0075319c0341 780 lcd.printf("%02d",h);
gelunar 1:0075319c0341 781
gelunar 1:0075319c0341 782 if (Alarm_IRDA()==-8)
gelunar 1:0075319c0341 783 {
gelunar 1:0075319c0341 784 i++;
gelunar 1:0075319c0341 785 m=0;
gelunar 1:0075319c0341 786 lcd.cls();
gelunar 1:0075319c0341 787 lcd.locate(0,0);
gelunar 1:0075319c0341 788 lcd.printf("Minuto: ");
gelunar 1:0075319c0341 789
gelunar 1:0075319c0341 790 }
gelunar 1:0075319c0341 791
gelunar 1:0075319c0341 792
gelunar 1:0075319c0341 793
gelunar 1:0075319c0341 794 case 6: //MINUTOS
gelunar 1:0075319c0341 795 m=0;
gelunar 1:0075319c0341 796 m=Alarm_IRDA();
gelunar 1:0075319c0341 797 if (m!=0)
gelunar 1:0075319c0341 798 {
gelunar 1:0075319c0341 799 min=m;
gelunar 1:0075319c0341 800 if(min>59)
gelunar 1:0075319c0341 801 {
gelunar 1:0075319c0341 802 min=59;
gelunar 1:0075319c0341 803 }
gelunar 1:0075319c0341 804 if(min<0)
gelunar 1:0075319c0341 805 {
gelunar 1:0075319c0341 806 min=0;
gelunar 1:0075319c0341 807 }
gelunar 1:0075319c0341 808
gelunar 1:0075319c0341 809 }
gelunar 1:0075319c0341 810 lcd.locate(8,0);
gelunar 1:0075319c0341 811 lcd.printf("%02d",min);
gelunar 1:0075319c0341 812
gelunar 1:0075319c0341 813 if (Alarm_IRDA()==-8)
gelunar 1:0075319c0341 814 {
gelunar 1:0075319c0341 815 i++;
gelunar 1:0075319c0341 816
gelunar 1:0075319c0341 817 lcd.cls();
gelunar 1:0075319c0341 818 lcd.locate(0,0);
gelunar 1:0075319c0341 819 lcd.printf("Segundo: ");
gelunar 1:0075319c0341 820
gelunar 1:0075319c0341 821 }
gelunar 1:0075319c0341 822
gelunar 1:0075319c0341 823
gelunar 1:0075319c0341 824
gelunar 1:0075319c0341 825
gelunar 1:0075319c0341 826 case 7: //SEGUNDOS
gelunar 1:0075319c0341 827 m=0;
gelunar 1:0075319c0341 828 m=Alarm_IRDA();
gelunar 1:0075319c0341 829 if (m!=0)
gelunar 1:0075319c0341 830 {
gelunar 1:0075319c0341 831 sec=m;
gelunar 1:0075319c0341 832 if(sec>59)
gelunar 1:0075319c0341 833 {
gelunar 1:0075319c0341 834 sec=59;
gelunar 1:0075319c0341 835 }
gelunar 1:0075319c0341 836 if(sec<0)
gelunar 1:0075319c0341 837 {
gelunar 1:0075319c0341 838 sec=0;
gelunar 1:0075319c0341 839 }
gelunar 1:0075319c0341 840
gelunar 1:0075319c0341 841 }
gelunar 1:0075319c0341 842
gelunar 1:0075319c0341 843 lcd.locate(8,0);
gelunar 1:0075319c0341 844 lcd.printf("%02d",sec);
gelunar 1:0075319c0341 845 if(Alarm_IRDA()==-8){
gelunar 1:0075319c0341 846
gelunar 1:0075319c0341 847 i++;
gelunar 1:0075319c0341 848
gelunar 1:0075319c0341 849 lcd.cls();
gelunar 1:0075319c0341 850
gelunar 1:0075319c0341 851
gelunar 1:0075319c0341 852 }
gelunar 1:0075319c0341 853
gelunar 1:0075319c0341 854 case 8:
gelunar 1:0075319c0341 855 m=0;
gelunar 1:0075319c0341 856 lcd.locate(0,1);
gelunar 1:0075319c0341 857 lcd.printf("\nAlarm:%02d:%02d:%02d",h,min,sec);
gelunar 1:0075319c0341 858 lcd.locate(2,0);
gelunar 1:0075319c0341 859 lcd.printf("\nFecha:%02d/%02d/%02d",d,mes,an);
gelunar 1:0075319c0341 860 wait(2.5);
gelunar 1:0075319c0341 861 lcd.cls();
gelunar 1:0075319c0341 862 lcd.locate(0,1);
gelunar 1:0075319c0341 863 lcd.printf("Alarma OK ?");
gelunar 1:0075319c0341 864 lcd.locate(2,0);
gelunar 1:0075319c0341 865 lcd.printf("--Si --No");
gelunar 1:0075319c0341 866 i++;
gelunar 1:0075319c0341 867
gelunar 1:0075319c0341 868
gelunar 1:0075319c0341 869
gelunar 1:0075319c0341 870 case 9:
gelunar 1:0075319c0341 871
gelunar 1:0075319c0341 872 m=Alarm_IRDA(); //
gelunar 1:0075319c0341 873 if(m==-2){
gelunar 1:0075319c0341 874 goto loop5;
gelunar 1:0075319c0341 875
gelunar 1:0075319c0341 876 }
gelunar 1:0075319c0341 877 if (m==-1){ //
gelunar 1:0075319c0341 878 pos++;
gelunar 1:0075319c0341 879
gelunar 1:0075319c0341 880 }
gelunar 1:0075319c0341 881 m=0;
gelunar 1:0075319c0341 882
gelunar 1:0075319c0341 883
gelunar 1:0075319c0341 884
gelunar 1:0075319c0341 885
gelunar 1:0075319c0341 886 }
gelunar 1:0075319c0341 887 switch (pos)
gelunar 1:0075319c0341 888 {
gelunar 1:0075319c0341 889 case 1:
gelunar 1:0075319c0341 890 if(s==0){
gelunar 1:0075319c0341 891 lcd.cls();
gelunar 1:0075319c0341 892 lcd.locate(0,1);
gelunar 1:0075319c0341 893 if(a==1){
gelunar 1:0075319c0341 894 Vec1[1]=d;
gelunar 1:0075319c0341 895 Vec1[2]=mes;
gelunar 1:0075319c0341 896 Vec1[3]=an;
gelunar 1:0075319c0341 897 Vec1[4]=h;
gelunar 1:0075319c0341 898 Vec1[5]=min;
gelunar 1:0075319c0341 899 Vec1[6]=sec;
gelunar 1:0075319c0341 900 }
gelunar 1:0075319c0341 901 if(a==2){
gelunar 1:0075319c0341 902 Vec2[1]=d;
gelunar 1:0075319c0341 903 Vec2[2]=mes;
gelunar 1:0075319c0341 904 Vec2[3]=an;
gelunar 1:0075319c0341 905 Vec2[4]=h;
gelunar 1:0075319c0341 906 Vec2[5]=min;
gelunar 1:0075319c0341 907 Vec2[6]=sec;
gelunar 1:0075319c0341 908 }
gelunar 1:0075319c0341 909 if(a==3){
gelunar 1:0075319c0341 910 Vec3[1]=d;
gelunar 1:0075319c0341 911 Vec3[2]=mes;
gelunar 1:0075319c0341 912 Vec3[3]=an;
gelunar 1:0075319c0341 913 Vec3[4]=h;
gelunar 1:0075319c0341 914 Vec3[5]=min;
gelunar 1:0075319c0341 915 Vec3[6]=sec;
gelunar 1:0075319c0341 916 }
gelunar 1:0075319c0341 917 if(a==4){
gelunar 1:0075319c0341 918 Vec4[1]=d;
gelunar 1:0075319c0341 919 Vec4[2]=mes;
gelunar 1:0075319c0341 920 Vec4[3]=an;
gelunar 1:0075319c0341 921 Vec4[4]=h;
gelunar 1:0075319c0341 922 Vec4[5]=min;
gelunar 1:0075319c0341 923 Vec4[6]=sec;
gelunar 1:0075319c0341 924 }
gelunar 1:0075319c0341 925 if(a==5){
gelunar 1:0075319c0341 926 Vec5[1]=d;
gelunar 1:0075319c0341 927 Vec5[2]=mes;
gelunar 1:0075319c0341 928 Vec5[3]=an;
gelunar 1:0075319c0341 929 Vec5[4]=h;
gelunar 1:0075319c0341 930 Vec5[5]=min;
gelunar 1:0075319c0341 931 Vec5[6]=sec;
gelunar 1:0075319c0341 932 }
gelunar 1:0075319c0341 933 if(a==6){
gelunar 1:0075319c0341 934 Vec6[1]=d;
gelunar 1:0075319c0341 935 Vec6[2]=mes;
gelunar 1:0075319c0341 936 Vec6[3]=an;
gelunar 1:0075319c0341 937 Vec6[4]=h;
gelunar 1:0075319c0341 938 Vec6[5]=min;
gelunar 1:0075319c0341 939 Vec6[6]=sec;
gelunar 1:0075319c0341 940 }
gelunar 1:0075319c0341 941 lcd.printf("Otra alarma? %0.2d",Vec1[6]);
gelunar 1:0075319c0341 942 lcd.locate(2,0);
gelunar 1:0075319c0341 943 lcd.printf("--Si --No");
gelunar 1:0075319c0341 944
gelunar 1:0075319c0341 945 pos++;
gelunar 1:0075319c0341 946 m=0;
gelunar 1:0075319c0341 947 }
gelunar 1:0075319c0341 948
gelunar 1:0075319c0341 949 case 2:
gelunar 1:0075319c0341 950 m=Alarm_IRDA(); // m son los datos del
gelunar 1:0075319c0341 951
gelunar 1:0075319c0341 952 if(m==-2){
gelunar 1:0075319c0341 953
gelunar 1:0075319c0341 954 lcd.cls();
gelunar 1:0075319c0341 955 m=0;
gelunar 1:0075319c0341 956 goto loop1;// Va al reloj
gelunar 1:0075319c0341 957 }
gelunar 1:0075319c0341 958 if(m==-1){
gelunar 1:0075319c0341 959
gelunar 1:0075319c0341 960 lcd.cls();
gelunar 1:0075319c0341 961 m=0;
gelunar 1:0075319c0341 962 goto loop3; //Va a alarma
gelunar 1:0075319c0341 963 }
gelunar 1:0075319c0341 964 break;
gelunar 1:0075319c0341 965
gelunar 1:0075319c0341 966 }
gelunar 1:0075319c0341 967
diavad 0:fd394f5c0449 968 }
gelunar 1:0075319c0341 969 switch (Lugar3)//Control
gelunar 1:0075319c0341 970 {
gelunar 1:0075319c0341 971 case 4:
gelunar 1:0075319c0341 972 ConfiReloj();
gelunar 1:0075319c0341 973 goto loop1;
gelunar 1:0075319c0341 974 break;
gelunar 1:0075319c0341 975 }
gelunar 1:0075319c0341 976 }
gelunar 1:0075319c0341 977 }
gelunar 1:0075319c0341 978 // ---- IRDA ----//
gelunar 1:0075319c0341 979
gelunar 1:0075319c0341 980 int detectar(void){
gelunar 1:0075319c0341 981 int y = 0;
gelunar 1:0075319c0341 982 header=0;
gelunar 1:0075319c0341 983 ledd2=1;
gelunar 1:0075319c0341 984 led=1;
gelunar 1:0075319c0341 985 header = irda.read_low_us(); //funcion para leer un pulso de caida o bajo en header
gelunar 1:0075319c0341 986 if (header > head_L && header < head_H){wait_us(2000);//verificar que este en la tolerancia +-20%
gelunar 1:0075319c0341 987
gelunar 1:0075319c0341 988 // ES EL TIEMPO DE HEADER QUE NO SE Lee O EL ALTO
gelunar 1:0075319c0341 989 ledd2=0;
gelunar 1:0075319c0341 990 for(il=0;il<(num_bits-1);++il){ // POR OSCILOSCOPIO se determina que llegan (num_bits),datos
gelunar 1:0075319c0341 991 dato = irda.read_high_us(); //leer un bit de datos que es pulso arriba en este control
gelunar 1:0075319c0341 992 num[il]=dato;
gelunar 1:0075319c0341 993 wait_us(300);
gelunar 1:0075319c0341 994 }
gelunar 1:0075319c0341 995 //espero un poquito luego de leer todo el arreglo y ponerlo en pantalla
gelunar 1:0075319c0341 996
gelunar 1:0075319c0341 997 for(il=0;il<(num_bits-1);++il){
gelunar 1:0075319c0341 998 if(num[il] > ((T_alto+T_bajo)/2)){ pc.printf("1");sel[il]='1';}
gelunar 1:0075319c0341 999 else {pc.printf("0");sel[il]='0';}
gelunar 1:0075319c0341 1000 }
gelunar 1:0075319c0341 1001 pc.printf("\n");
gelunar 1:0075319c0341 1002 y = 1;
gelunar 1:0075319c0341 1003 pc.printf("%d",y);
gelunar 1:0075319c0341 1004 }
gelunar 1:0075319c0341 1005 return y;
gelunar 1:0075319c0341 1006 }
gelunar 1:0075319c0341 1007
gelunar 1:0075319c0341 1008 int irdan(void){
gelunar 1:0075319c0341 1009 int numirda;
gelunar 1:0075319c0341 1010
gelunar 1:0075319c0341 1011
gelunar 1:0075319c0341 1012 for(il=0; il<32; ++il)
diavad 0:fd394f5c0449 1013 {
gelunar 1:0075319c0341 1014 if(!strcmp(sel,uno))
gelunar 1:0075319c0341 1015 {
gelunar 1:0075319c0341 1016 numirda=1;
gelunar 1:0075319c0341 1017 break;
gelunar 1:0075319c0341 1018 }
gelunar 1:0075319c0341 1019 if(!strcmp(sel,dos))
gelunar 1:0075319c0341 1020 {
gelunar 1:0075319c0341 1021 numirda=2;
gelunar 1:0075319c0341 1022 }
gelunar 1:0075319c0341 1023 if(!strcmp(sel,tres))
diavad 0:fd394f5c0449 1024 {
gelunar 1:0075319c0341 1025 numirda=3;
gelunar 1:0075319c0341 1026 }
gelunar 1:0075319c0341 1027 if(!strcmp(sel,cuatro))
gelunar 1:0075319c0341 1028 {
gelunar 1:0075319c0341 1029 numirda=4;
gelunar 1:0075319c0341 1030 }
gelunar 1:0075319c0341 1031 if(!strcmp(sel,cinco))
gelunar 1:0075319c0341 1032 {
gelunar 1:0075319c0341 1033 numirda=5;
gelunar 1:0075319c0341 1034 }
gelunar 1:0075319c0341 1035 if(!strcmp(sel,seis))
gelunar 1:0075319c0341 1036 {
gelunar 1:0075319c0341 1037 numirda=6;
diavad 0:fd394f5c0449 1038 }
gelunar 1:0075319c0341 1039 if(!strcmp(sel,siete))
gelunar 1:0075319c0341 1040 {
gelunar 1:0075319c0341 1041 numirda=7;
gelunar 1:0075319c0341 1042 }
gelunar 1:0075319c0341 1043 if(!strcmp(sel,ocho))
gelunar 1:0075319c0341 1044 {
gelunar 1:0075319c0341 1045 numirda=8;
gelunar 1:0075319c0341 1046 }
gelunar 1:0075319c0341 1047 if(!strcmp(sel,nueve))
gelunar 1:0075319c0341 1048 {
gelunar 1:0075319c0341 1049 numirda=9;
gelunar 1:0075319c0341 1050 }
gelunar 1:0075319c0341 1051 if(!strcmp(sel,cero))
diavad 0:fd394f5c0449 1052 {
gelunar 1:0075319c0341 1053 numirda=0;
gelunar 1:0075319c0341 1054 }
gelunar 1:0075319c0341 1055 if(!strcmp(sel,ok))
gelunar 1:0075319c0341 1056 {
gelunar 1:0075319c0341 1057 numirda=-8;
diavad 0:fd394f5c0449 1058 }
gelunar 1:0075319c0341 1059 if(!strcmp(sel,izq))
gelunar 1:0075319c0341 1060 {
gelunar 1:0075319c0341 1061 numirda=-1;
gelunar 1:0075319c0341 1062 }
gelunar 1:0075319c0341 1063 if(!strcmp(sel,der))
gelunar 1:0075319c0341 1064 {
gelunar 1:0075319c0341 1065 numirda=-2;
gelunar 1:0075319c0341 1066 }
gelunar 1:0075319c0341 1067 }
gelunar 1:0075319c0341 1068 return numirda;
diavad 0:fd394f5c0449 1069 }
diavad 0:fd394f5c0449 1070
gelunar 1:0075319c0341 1071 int ConfiReloj(void){
diavad 0:fd394f5c0449 1072 Rtc_Ds1307::Time_rtc tm = {};
diavad 0:fd394f5c0449 1073 //;config = 0,config = 0,config = 0,ano = 2019,hora = 0, min = 0,
diavad 0:fd394f5c0449 1074 int configR = 0, cont = 1, set = 0;
diavad 0:fd394f5c0449 1075 int estado = 1;
diavad 0:fd394f5c0449 1076 wait(0.2);
diavad 0:fd394f5c0449 1077 while(estado == 1){
diavad 0:fd394f5c0449 1078 if(configR == 0) {
diavad 0:fd394f5c0449 1079 lcd.cls();
diavad 0:fd394f5c0449 1080 lcd.locate(0,0);
diavad 0:fd394f5c0449 1081 lcd.printf("Configurar reloj");
diavad 0:fd394f5c0449 1082 set = set + wheel.getPulses();
diavad 0:fd394f5c0449 1083 pc.printf("%i",set);
diavad 0:fd394f5c0449 1084 wheel.reset();
diavad 0:fd394f5c0449 1085 if(set > 1) {
diavad 0:fd394f5c0449 1086 set = 0;
diavad 0:fd394f5c0449 1087 }
diavad 0:fd394f5c0449 1088 if(set < 0) {
diavad 0:fd394f5c0449 1089 set = 1;
diavad 0:fd394f5c0449 1090 }
diavad 0:fd394f5c0449 1091 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1092 if(set == 0) {
diavad 0:fd394f5c0449 1093 lcd.printf(" NO ");
diavad 0:fd394f5c0449 1094 //wait_ms(10);
diavad 0:fd394f5c0449 1095
diavad 0:fd394f5c0449 1096 } else if(set == 1) {
diavad 0:fd394f5c0449 1097 lcd.printf(" SI ");
diavad 0:fd394f5c0449 1098 //wait_ms(10);
diavad 0:fd394f5c0449 1099 }
gelunar 1:0075319c0341 1100 if(bot1.falling()){
diavad 0:fd394f5c0449 1101 if(set==1){
diavad 0:fd394f5c0449 1102 configR=1;
diavad 0:fd394f5c0449 1103 }else if(set!=1){
diavad 0:fd394f5c0449 1104 configR=0;
diavad 0:fd394f5c0449 1105 estado=0;
diavad 0:fd394f5c0449 1106 }
diavad 0:fd394f5c0449 1107 }
diavad 0:fd394f5c0449 1108 }
diavad 0:fd394f5c0449 1109 if(configR == 1) {
diavad 0:fd394f5c0449 1110 cont = cont + wheel.getPulses();
diavad 0:fd394f5c0449 1111 wheel.reset();
diavad 0:fd394f5c0449 1112 if(cont > 31) {
diavad 0:fd394f5c0449 1113 cont = 1;
diavad 0:fd394f5c0449 1114 }
diavad 0:fd394f5c0449 1115 if(cont < 1) {
diavad 0:fd394f5c0449 1116 cont = 31;
diavad 0:fd394f5c0449 1117 }
diavad 0:fd394f5c0449 1118 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1119 lcd.printf("Dia: %02d ", cont);
diavad 0:fd394f5c0449 1120 tm.date = cont;
gelunar 1:0075319c0341 1121 if(bot1.falling()){
diavad 0:fd394f5c0449 1122
diavad 0:fd394f5c0449 1123 configR=2;
diavad 0:fd394f5c0449 1124 }
diavad 0:fd394f5c0449 1125 }
diavad 0:fd394f5c0449 1126 if(configR == 2) {
diavad 0:fd394f5c0449 1127 cont = cont + wheel.getPulses();
diavad 0:fd394f5c0449 1128 wheel.reset();
diavad 0:fd394f5c0449 1129 if(cont > 12) {
diavad 0:fd394f5c0449 1130 cont = 1;
diavad 0:fd394f5c0449 1131 }
diavad 0:fd394f5c0449 1132 if(cont < 1) {
diavad 0:fd394f5c0449 1133 cont = 12;
diavad 0:fd394f5c0449 1134 }
diavad 0:fd394f5c0449 1135 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1136 lcd.printf("Mes: %02d ", cont);
diavad 0:fd394f5c0449 1137
gelunar 1:0075319c0341 1138 if(bot1.falling()){
diavad 0:fd394f5c0449 1139 tm.mon = cont;
diavad 0:fd394f5c0449 1140 configR = 3;
diavad 0:fd394f5c0449 1141 }
diavad 0:fd394f5c0449 1142 }
diavad 0:fd394f5c0449 1143 if(configR == 3) {
diavad 0:fd394f5c0449 1144 cont = cont + wheel.getPulses();
diavad 0:fd394f5c0449 1145 wheel.reset();
diavad 0:fd394f5c0449 1146 if(cont > 3000) {
diavad 0:fd394f5c0449 1147 cont = 2016;
diavad 0:fd394f5c0449 1148 }
diavad 0:fd394f5c0449 1149 if(cont < 2016) {
diavad 0:fd394f5c0449 1150 cont = 2016;
diavad 0:fd394f5c0449 1151 }
diavad 0:fd394f5c0449 1152 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1153 lcd.printf("Anno: %02d ", cont);
diavad 0:fd394f5c0449 1154
gelunar 1:0075319c0341 1155 if(bot1.falling()){
diavad 0:fd394f5c0449 1156 tm.year = cont;
diavad 0:fd394f5c0449 1157 configR = 4;
diavad 0:fd394f5c0449 1158 }
diavad 0:fd394f5c0449 1159 }
diavad 0:fd394f5c0449 1160 if(configR == 4) {
diavad 0:fd394f5c0449 1161 cont = cont + wheel.getPulses();
diavad 0:fd394f5c0449 1162 wheel.reset();
diavad 0:fd394f5c0449 1163 if(cont > 7) {
diavad 0:fd394f5c0449 1164 cont = 1;
diavad 0:fd394f5c0449 1165 }
diavad 0:fd394f5c0449 1166 if(cont < 1) {
diavad 0:fd394f5c0449 1167 cont = 7;
diavad 0:fd394f5c0449 1168 }
diavad 0:fd394f5c0449 1169 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1170 lcd.printf("Dia semana: %1d", cont);
diavad 0:fd394f5c0449 1171 //tm.wday = cont;
diavad 0:fd394f5c0449 1172
gelunar 1:0075319c0341 1173 if(bot1.falling()){
diavad 0:fd394f5c0449 1174 tm.wday = cont;
diavad 0:fd394f5c0449 1175 configR = 5;
diavad 0:fd394f5c0449 1176 }
diavad 0:fd394f5c0449 1177 }
diavad 0:fd394f5c0449 1178 if(configR == 5) {
diavad 0:fd394f5c0449 1179 cont = cont + wheel.getPulses();
diavad 0:fd394f5c0449 1180 wheel.reset();
diavad 0:fd394f5c0449 1181 if(cont > 23) {
diavad 0:fd394f5c0449 1182 cont = 0;
diavad 0:fd394f5c0449 1183 }
diavad 0:fd394f5c0449 1184 if(cont < 0) {
diavad 0:fd394f5c0449 1185 cont = 23;
diavad 0:fd394f5c0449 1186 }
diavad 0:fd394f5c0449 1187 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1188 lcd.printf("Hora: %02d ", cont);
diavad 0:fd394f5c0449 1189 //tm.hour = cont;
gelunar 1:0075319c0341 1190 if(bot1.falling()){
diavad 0:fd394f5c0449 1191 tm.hour = cont;
diavad 0:fd394f5c0449 1192 configR = 6;
diavad 0:fd394f5c0449 1193 }
diavad 0:fd394f5c0449 1194 }
diavad 0:fd394f5c0449 1195 if(configR == 6) {
diavad 0:fd394f5c0449 1196 cont = cont + wheel.getPulses();
diavad 0:fd394f5c0449 1197 wheel.reset();
diavad 0:fd394f5c0449 1198 if(cont > 59) {
diavad 0:fd394f5c0449 1199 cont = 0;
diavad 0:fd394f5c0449 1200 }
diavad 0:fd394f5c0449 1201 if(cont < 0) {
diavad 0:fd394f5c0449 1202 cont = 59;
diavad 0:fd394f5c0449 1203 }
diavad 0:fd394f5c0449 1204 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1205 lcd.printf("Minutos: %02d ", cont);
diavad 0:fd394f5c0449 1206 //tm.min = cont;
gelunar 1:0075319c0341 1207 if(bot1.falling()){
diavad 0:fd394f5c0449 1208 tm.min = cont;
diavad 0:fd394f5c0449 1209 configR = 7;
diavad 0:fd394f5c0449 1210 }
diavad 0:fd394f5c0449 1211 }
diavad 0:fd394f5c0449 1212 if(configR == 7) {
diavad 0:fd394f5c0449 1213 cont = cont + wheel.getPulses();
diavad 0:fd394f5c0449 1214 wheel.reset();
diavad 0:fd394f5c0449 1215 if(cont > 59) {
diavad 0:fd394f5c0449 1216 cont = 0;
diavad 0:fd394f5c0449 1217 }
diavad 0:fd394f5c0449 1218 if(cont < 0) {
diavad 0:fd394f5c0449 1219 cont = 59;
diavad 0:fd394f5c0449 1220 }
diavad 0:fd394f5c0449 1221 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1222 lcd.printf("Segundos: %02d ", cont);
diavad 0:fd394f5c0449 1223 tm.sec = cont;
gelunar 1:0075319c0341 1224 if(bot1.falling()){
diavad 0:fd394f5c0449 1225 tm.sec = cont;
diavad 0:fd394f5c0449 1226 configR = 8;
diavad 0:fd394f5c0449 1227 }
diavad 0:fd394f5c0449 1228 }
diavad 0:fd394f5c0449 1229 if(configR == 8) {
diavad 0:fd394f5c0449 1230 lcd.locate(0, 1);
diavad 0:fd394f5c0449 1231 lcd.printf(" Establecido ");
diavad 0:fd394f5c0449 1232 rtc.setTime(tm, false, false);
diavad 0:fd394f5c0449 1233 rtc.startClock();
diavad 0:fd394f5c0449 1234 //estado = 0;
diavad 0:fd394f5c0449 1235 configR = 0;
diavad 0:fd394f5c0449 1236 estado=0;
diavad 0:fd394f5c0449 1237 wait(2);
gelunar 1:0075319c0341 1238
diavad 0:fd394f5c0449 1239 }
diavad 0:fd394f5c0449 1240 }
diavad 0:fd394f5c0449 1241 }
gelunar 1:0075319c0341 1242
gelunar 1:0075319c0341 1243
gelunar 1:0075319c0341 1244
gelunar 1:0075319c0341 1245 int Alarm_IRDA(void){
gelunar 1:0075319c0341 1246 int x1 = 0, x2 = 0, x3 = 0, c = 0;
diavad 0:fd394f5c0449 1247
gelunar 1:0075319c0341 1248 while(1){
gelunar 1:0075319c0341 1249 if (detectar() == 1){
gelunar 1:0075319c0341 1250 c++;
gelunar 1:0075319c0341 1251 if(c == 1){
gelunar 1:0075319c0341 1252 x1 = irdan();
gelunar 1:0075319c0341 1253 pc.printf("\nx1: %d c: %d\n",x1,c);
gelunar 1:0075319c0341 1254 x = x1;
gelunar 1:0075319c0341 1255 if(x1==-8){
gelunar 1:0075319c0341 1256 x=x1;
gelunar 1:0075319c0341 1257 break;
gelunar 1:0075319c0341 1258 }
gelunar 1:0075319c0341 1259 pc.printf("\nx: %02d",x);
gelunar 1:0075319c0341 1260 pc.printf("num: %032d",irdan());
gelunar 1:0075319c0341 1261 }//c1
gelunar 1:0075319c0341 1262
gelunar 1:0075319c0341 1263 if(c == 2){
gelunar 1:0075319c0341 1264 x2 = irdan();
gelunar 1:0075319c0341 1265 pc.printf("\nx2: %d c: %d\n",x2,c);
gelunar 1:0075319c0341 1266 if( x2 == -8){
gelunar 1:0075319c0341 1267 x = x1;
gelunar 1:0075319c0341 1268 pc.printf("\nx: %02d",x);
gelunar 1:0075319c0341 1269 pc.printf("num: %032d",sel);
gelunar 1:0075319c0341 1270 break;
gelunar 1:0075319c0341 1271 }
gelunar 1:0075319c0341 1272 else{
gelunar 1:0075319c0341 1273 x = x1*10 + x2;
gelunar 1:0075319c0341 1274 pc.printf("\nx: %02d",x);
gelunar 1:0075319c0341 1275 pc.printf("num: %032d",sel);
gelunar 1:0075319c0341 1276
gelunar 1:0075319c0341 1277 }
gelunar 1:0075319c0341 1278
gelunar 1:0075319c0341 1279
gelunar 1:0075319c0341 1280 }//c2
gelunar 1:0075319c0341 1281 if (c == 3){
gelunar 1:0075319c0341 1282 x3 = irdan();
gelunar 1:0075319c0341 1283 pc.printf("\nx3: %d c: %d\n",x3,c);
gelunar 1:0075319c0341 1284 pc.printf("\nx: %02d",x);
gelunar 1:0075319c0341 1285 pc.printf("num: %032d",sel);
gelunar 1:0075319c0341 1286 if( x3 == -8){
gelunar 1:0075319c0341 1287 x = ((x1*10) + x2);
gelunar 1:0075319c0341 1288 pc.printf("\nx: %02d",x);
gelunar 1:0075319c0341 1289 pc.printf("num: %032d",sel);
gelunar 1:0075319c0341 1290 break;
gelunar 1:0075319c0341 1291 }
gelunar 1:0075319c0341 1292 } //c3
gelunar 1:0075319c0341 1293 }//detectar
gelunar 1:0075319c0341 1294
gelunar 1:0075319c0341 1295 }//while
gelunar 1:0075319c0341 1296 return x;
gelunar 1:0075319c0341 1297
gelunar 1:0075319c0341 1298 }//funcion