![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Configura 7 alarmas usando un modulo rtc ds1307 y un control remoto de televisor samsung
Dependencies: Debounced Pulse1 QEI RTC-DS1307 TextLCD mbed
Fork of Reloj_alarma by
main.cpp@2:36ae76508d25, 2018-06-05 (annotated)
- Committer:
- jufzapataov
- Date:
- Tue Jun 05 03:47:13 2018 +0000
- Revision:
- 2:36ae76508d25
- Parent:
- 1:0639f31dd59f
none
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jufzapataov | 2:36ae76508d25 | 1 | /* |
jufzapataov | 2:36ae76508d25 | 2 | Programa que configura siete alarmas definidas por el usuario mediante un control remoto de televisor |
jufzapataov | 2:36ae76508d25 | 3 | samsung con los botones del 1 al 7, tarea desarrollada por Santiago Gomez Estrada, Juan Fernando Zapata Oviedo y |
jufzapataov | 2:36ae76508d25 | 4 | Matero sepulveda |
jufzapataov | 2:36ae76508d25 | 5 | */ |
jufzapataov | 2:36ae76508d25 | 6 | |
Jepalacioh | 0:c2ed510ee88d | 7 | #include "mbed.h" |
Jepalacioh | 0:c2ed510ee88d | 8 | #include "DebouncedIn.h" |
Jepalacioh | 0:c2ed510ee88d | 9 | #include "TextLCD.h" |
Jepalacioh | 0:c2ed510ee88d | 10 | #include "QEI.h" |
Jepalacioh | 0:c2ed510ee88d | 11 | #include "Rtc_Ds1307.h" |
jufzapataov | 2:36ae76508d25 | 12 | #include "string.h" |
jufzapataov | 2:36ae76508d25 | 13 | #include <Pulse1.h> |
jufzapataov | 2:36ae76508d25 | 14 | Serial pc(USBTX, USBRX); |
jufzapataov | 2:36ae76508d25 | 15 | |
jufzapataov | 2:36ae76508d25 | 16 | PulseInOut sensor(PTB0); |
Jepalacioh | 0:c2ed510ee88d | 17 | |
Jepalacioh | 0:c2ed510ee88d | 18 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 |
jufzapataov | 2:36ae76508d25 | 19 | |
Jepalacioh | 0:c2ed510ee88d | 20 | Rtc_Ds1307 rtc(PTE0, PTE1); |
Jepalacioh | 0:c2ed510ee88d | 21 | QEI wheel (PTA16, PTA17, NC, 48); |
jufzapataov | 2:36ae76508d25 | 22 | DebouncedIn button_enco(PTC5); |
jufzapataov | 2:36ae76508d25 | 23 | DigitalOut myled(LED3); |
Jepalacioh | 0:c2ed510ee88d | 24 | |
Jepalacioh | 0:c2ed510ee88d | 25 | |
jufzapataov | 2:36ae76508d25 | 26 | char stri[33]; |
jufzapataov | 2:36ae76508d25 | 27 | // cadenas que representan de las teclas 1 a 7 del control remoto samsung |
jufzapataov | 2:36ae76508d25 | 28 | char Tec1[33]="11100000111000000010000011011111"; |
jufzapataov | 2:36ae76508d25 | 29 | char Tec2[33]="11100000111000001010000001011111"; |
jufzapataov | 2:36ae76508d25 | 30 | char Tec3[33]="11100000111000000110000010011111"; |
jufzapataov | 2:36ae76508d25 | 31 | char Tec4[33]="11100000111000000001000011101111"; |
jufzapataov | 2:36ae76508d25 | 32 | char Tec5[33]="11100000111000001001000001101111"; |
jufzapataov | 2:36ae76508d25 | 33 | char Tec6[33]="11100000111000000101000010101111"; |
jufzapataov | 2:36ae76508d25 | 34 | char Tec7[33]="11100000111000000011000011001111"; |
jufzapataov | 2:36ae76508d25 | 35 | char TecSet[33]="11111111111111111000001110000000"; |
jufzapataov | 2:36ae76508d25 | 36 | int mode=0; |
jufzapataov | 2:36ae76508d25 | 37 | int code; |
jufzapataov | 2:36ae76508d25 | 38 | int numb=32; |
jufzapataov | 2:36ae76508d25 | 39 | int s=0; |
jufzapataov | 2:36ae76508d25 | 40 | // |
Jepalacioh | 0:c2ed510ee88d | 41 | |
jufzapataov | 2:36ae76508d25 | 42 | |
jufzapataov | 2:36ae76508d25 | 43 | int conv[28]; |
jufzapataov | 2:36ae76508d25 | 44 | int bin[28];//almacena tiempos que conforman los bits de datos |
jufzapataov | 2:36ae76508d25 | 45 | int d; // |
jufzapataov | 2:36ae76508d25 | 46 | int pul_low; |
jufzapataov | 2:36ae76508d25 | 47 | int i1,j1,k1,header,proL,proH; |
jufzapataov | 2:36ae76508d25 | 48 | char r; |
jufzapataov | 2:36ae76508d25 | 49 | |
jufzapataov | 2:36ae76508d25 | 50 | int P[28];//almacena tiempos que conforman los bits de datos rellenos |
jufzapataov | 2:36ae76508d25 | 51 | int N[28];// almacena tiempos que conforman los bits de datos vacios |
jufzapataov | 2:36ae76508d25 | 52 | |
Jepalacioh | 0:c2ed510ee88d | 53 | int C1=0x0C; |
tony63 | 1:0639f31dd59f | 54 | int m; |
Jepalacioh | 0:c2ed510ee88d | 55 | int Conf=0; // 0: Alarma y 1:Reloj |
Jepalacioh | 0:c2ed510ee88d | 56 | int Lugar=0; // Definen el punto en el cual va el programa |
Jepalacioh | 0:c2ed510ee88d | 57 | int i=0; |
jufzapataov | 2:36ae76508d25 | 58 | int j=1; |
jufzapataov | 2:36ae76508d25 | 59 | int irda=1; |
jufzapataov | 2:36ae76508d25 | 60 | int sensor_en=0; |
Jepalacioh | 0:c2ed510ee88d | 61 | int visual=0; |
jufzapataov | 2:36ae76508d25 | 62 | int alarma=0; |
Jepalacioh | 0:c2ed510ee88d | 63 | int main() |
Jepalacioh | 0:c2ed510ee88d | 64 | { |
jufzapataov | 2:36ae76508d25 | 65 | myled=1; |
jufzapataov | 2:36ae76508d25 | 66 | j=1; |
jufzapataov | 2:36ae76508d25 | 67 | Rtc_Ds1307::Time_rtc tm2 = {}; |
Jepalacioh | 0:c2ed510ee88d | 68 | Rtc_Ds1307::Time_rtc tm = {}; |
jufzapataov | 2:36ae76508d25 | 69 | Rtc_Ds1307::Time_rtc Alarmas[8] = {}; |
Jepalacioh | 0:c2ed510ee88d | 70 | lcd.cls(); |
jufzapataov | 2:36ae76508d25 | 71 | |
Jepalacioh | 0:c2ed510ee88d | 72 | lcd.writeCommand(C1);//escribimos un comando segun el manual del modulo LCD |
Jepalacioh | 0:c2ed510ee88d | 73 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 74 | lcd.printf("--Alarmas --Hora"); |
tony63 | 1:0639f31dd59f | 75 | rtc.getTime(tm); //lee el tiempo del DS1307 |
Jepalacioh | 0:c2ed510ee88d | 76 | |
jufzapataov | 2:36ae76508d25 | 77 | |
jufzapataov | 2:36ae76508d25 | 78 | |
Jepalacioh | 0:c2ed510ee88d | 79 | while(1) |
Jepalacioh | 0:c2ed510ee88d | 80 | { |
jufzapataov | 2:36ae76508d25 | 81 | |
Jepalacioh | 0:c2ed510ee88d | 82 | switch (Lugar) |
Jepalacioh | 0:c2ed510ee88d | 83 | { |
Jepalacioh | 0:c2ed510ee88d | 84 | case 0: |
tony63 | 1:0639f31dd59f | 85 | m=wheel.getPulses(); // m son los datos del encoder |
Jepalacioh | 0:c2ed510ee88d | 86 | if(m!=0 && Conf==0){ |
Jepalacioh | 0:c2ed510ee88d | 87 | Conf=1; |
Jepalacioh | 0:c2ed510ee88d | 88 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 89 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 90 | } |
Jepalacioh | 0:c2ed510ee88d | 91 | |
jufzapataov | 2:36ae76508d25 | 92 | if(m!=0 && Conf==1){ |
Jepalacioh | 0:c2ed510ee88d | 93 | Conf=0; |
Jepalacioh | 0:c2ed510ee88d | 94 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 95 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 96 | } |
Jepalacioh | 0:c2ed510ee88d | 97 | |
Jepalacioh | 0:c2ed510ee88d | 98 | if(Conf==0){ |
Jepalacioh | 0:c2ed510ee88d | 99 | |
Jepalacioh | 0:c2ed510ee88d | 100 | lcd.locate(11,0); |
Jepalacioh | 0:c2ed510ee88d | 101 | lcd.printf("-"); |
Jepalacioh | 0:c2ed510ee88d | 102 | lcd.locate(1,0); |
Jepalacioh | 0:c2ed510ee88d | 103 | lcd.printf(">"); |
Jepalacioh | 0:c2ed510ee88d | 104 | lcd.locate(0,1); |
Jepalacioh | 0:c2ed510ee88d | 105 | wait(0.1); |
Jepalacioh | 0:c2ed510ee88d | 106 | |
Jepalacioh | 0:c2ed510ee88d | 107 | } |
Jepalacioh | 0:c2ed510ee88d | 108 | |
Jepalacioh | 0:c2ed510ee88d | 109 | if(Conf==1){ |
Jepalacioh | 0:c2ed510ee88d | 110 | |
Jepalacioh | 0:c2ed510ee88d | 111 | lcd.locate(1,0); |
Jepalacioh | 0:c2ed510ee88d | 112 | lcd.printf("-"); |
Jepalacioh | 0:c2ed510ee88d | 113 | lcd.locate(11,0); |
Jepalacioh | 0:c2ed510ee88d | 114 | lcd.printf(">"); |
Jepalacioh | 0:c2ed510ee88d | 115 | lcd.locate(0,1); |
Jepalacioh | 0:c2ed510ee88d | 116 | wait(0.1); |
Jepalacioh | 0:c2ed510ee88d | 117 | } |
Jepalacioh | 0:c2ed510ee88d | 118 | |
tony63 | 1:0639f31dd59f | 119 | if (button_enco.falling()){ //si se pulsa boton encoder |
Jepalacioh | 0:c2ed510ee88d | 120 | Lugar++; |
Jepalacioh | 0:c2ed510ee88d | 121 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 122 | } |
Jepalacioh | 0:c2ed510ee88d | 123 | |
Jepalacioh | 0:c2ed510ee88d | 124 | break; |
Jepalacioh | 0:c2ed510ee88d | 125 | |
jufzapataov | 2:36ae76508d25 | 126 | // configura las opciones de alarma: dia, fecha, hora(hh:mm:seg) |
Jepalacioh | 0:c2ed510ee88d | 127 | case 1: |
Jepalacioh | 0:c2ed510ee88d | 128 | switch(i) |
Jepalacioh | 0:c2ed510ee88d | 129 | { |
jufzapataov | 2:36ae76508d25 | 130 | case 0: |
jufzapataov | 2:36ae76508d25 | 131 | if(Conf==0) // ALARMA |
Jepalacioh | 0:c2ed510ee88d | 132 | { |
Jepalacioh | 0:c2ed510ee88d | 133 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 134 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 135 | lcd.printf("Config. Alarmas "); |
Jepalacioh | 0:c2ed510ee88d | 136 | wait(1); |
jufzapataov | 2:36ae76508d25 | 137 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 138 | i++; |
Jepalacioh | 0:c2ed510ee88d | 139 | lcd.locate(0,0); |
Jepalacioh | 0:c2ed510ee88d | 140 | lcd.printf("Dia: "); |
jufzapataov | 2:36ae76508d25 | 141 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 142 | } |
Jepalacioh | 0:c2ed510ee88d | 143 | |
jufzapataov | 2:36ae76508d25 | 144 | if(Conf==1) //RELOJ |
Jepalacioh | 0:c2ed510ee88d | 145 | { |
Jepalacioh | 0:c2ed510ee88d | 146 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 147 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 148 | lcd.printf("Config. Tiempo"); |
Jepalacioh | 0:c2ed510ee88d | 149 | wait(1); |
Jepalacioh | 0:c2ed510ee88d | 150 | i++; |
Jepalacioh | 0:c2ed510ee88d | 151 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 152 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 153 | lcd.printf("Tiempo: "); |
jufzapataov | 2:36ae76508d25 | 154 | m=0; |
tony63 | 1:0639f31dd59f | 155 | |
Jepalacioh | 0:c2ed510ee88d | 156 | } |
Jepalacioh | 0:c2ed510ee88d | 157 | |
Jepalacioh | 0:c2ed510ee88d | 158 | break; |
jufzapataov | 2:36ae76508d25 | 159 | |
jufzapataov | 2:36ae76508d25 | 160 | // configura las opciones de reloj: dia, fecha, hora(hh:mm:seg) |
jufzapataov | 2:36ae76508d25 | 161 | case 1: //dia de la semana |
jufzapataov | 2:36ae76508d25 | 162 | m=wheel.getPulses(); |
jufzapataov | 2:36ae76508d25 | 163 | if (m!=0) |
jufzapataov | 2:36ae76508d25 | 164 | { |
jufzapataov | 2:36ae76508d25 | 165 | tm.wday=tm.wday+m; |
jufzapataov | 2:36ae76508d25 | 166 | if(tm.wday>7) |
jufzapataov | 2:36ae76508d25 | 167 | { |
jufzapataov | 2:36ae76508d25 | 168 | tm.wday=7; |
jufzapataov | 2:36ae76508d25 | 169 | } |
jufzapataov | 2:36ae76508d25 | 170 | if(tm.wday<1) |
jufzapataov | 2:36ae76508d25 | 171 | { |
jufzapataov | 2:36ae76508d25 | 172 | tm.wday=1; |
jufzapataov | 2:36ae76508d25 | 173 | } |
jufzapataov | 2:36ae76508d25 | 174 | |
jufzapataov | 2:36ae76508d25 | 175 | wheel.reset(); |
jufzapataov | 2:36ae76508d25 | 176 | m=0; |
jufzapataov | 2:36ae76508d25 | 177 | } |
jufzapataov | 2:36ae76508d25 | 178 | |
jufzapataov | 2:36ae76508d25 | 179 | switch(tm.wday){ |
jufzapataov | 2:36ae76508d25 | 180 | case (1): |
jufzapataov | 2:36ae76508d25 | 181 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 182 | lcd.printf("Domingo"); |
jufzapataov | 2:36ae76508d25 | 183 | break; |
jufzapataov | 2:36ae76508d25 | 184 | case (2): |
jufzapataov | 2:36ae76508d25 | 185 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 186 | lcd.printf("Lunes"); |
jufzapataov | 2:36ae76508d25 | 187 | break; |
jufzapataov | 2:36ae76508d25 | 188 | case (3): |
jufzapataov | 2:36ae76508d25 | 189 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 190 | lcd.printf("Martes"); |
jufzapataov | 2:36ae76508d25 | 191 | break; |
jufzapataov | 2:36ae76508d25 | 192 | case (4): |
jufzapataov | 2:36ae76508d25 | 193 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 194 | lcd.printf("Miercoles"); |
jufzapataov | 2:36ae76508d25 | 195 | break; |
jufzapataov | 2:36ae76508d25 | 196 | case (5): |
jufzapataov | 2:36ae76508d25 | 197 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 198 | lcd.printf("jueves"); |
jufzapataov | 2:36ae76508d25 | 199 | break; |
jufzapataov | 2:36ae76508d25 | 200 | case (6): |
jufzapataov | 2:36ae76508d25 | 201 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 202 | lcd.printf("viernes"); |
jufzapataov | 2:36ae76508d25 | 203 | break; |
jufzapataov | 2:36ae76508d25 | 204 | case (7): |
jufzapataov | 2:36ae76508d25 | 205 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 206 | lcd.printf("Sabado"); |
jufzapataov | 2:36ae76508d25 | 207 | break; |
jufzapataov | 2:36ae76508d25 | 208 | } |
jufzapataov | 2:36ae76508d25 | 209 | |
jufzapataov | 2:36ae76508d25 | 210 | |
jufzapataov | 2:36ae76508d25 | 211 | if (button_enco.falling()) |
jufzapataov | 2:36ae76508d25 | 212 | { |
jufzapataov | 2:36ae76508d25 | 213 | switch(Conf) |
jufzapataov | 2:36ae76508d25 | 214 | { |
jufzapataov | 2:36ae76508d25 | 215 | case 0: |
jufzapataov | 2:36ae76508d25 | 216 | i=5; |
jufzapataov | 2:36ae76508d25 | 217 | m=0; |
jufzapataov | 2:36ae76508d25 | 218 | lcd.cls(); |
jufzapataov | 2:36ae76508d25 | 219 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 220 | lcd.printf("Hora: "); |
jufzapataov | 2:36ae76508d25 | 221 | m=0; |
jufzapataov | 2:36ae76508d25 | 222 | break; |
jufzapataov | 2:36ae76508d25 | 223 | case 1: |
jufzapataov | 2:36ae76508d25 | 224 | i=2; |
jufzapataov | 2:36ae76508d25 | 225 | m=0; |
jufzapataov | 2:36ae76508d25 | 226 | lcd.cls(); |
jufzapataov | 2:36ae76508d25 | 227 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 228 | lcd.printf("Dia: "); |
jufzapataov | 2:36ae76508d25 | 229 | break; |
jufzapataov | 2:36ae76508d25 | 230 | } |
jufzapataov | 2:36ae76508d25 | 231 | } |
Jepalacioh | 0:c2ed510ee88d | 232 | |
jufzapataov | 2:36ae76508d25 | 233 | break; |
jufzapataov | 2:36ae76508d25 | 234 | |
jufzapataov | 2:36ae76508d25 | 235 | case 2: // |
jufzapataov | 2:36ae76508d25 | 236 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 237 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 238 | if (m!=0) |
Jepalacioh | 0:c2ed510ee88d | 239 | { |
Jepalacioh | 0:c2ed510ee88d | 240 | tm.date=tm.date+m; |
Jepalacioh | 0:c2ed510ee88d | 241 | if(tm.date>31) |
Jepalacioh | 0:c2ed510ee88d | 242 | { |
Jepalacioh | 0:c2ed510ee88d | 243 | tm.date=31; |
Jepalacioh | 0:c2ed510ee88d | 244 | } |
Jepalacioh | 0:c2ed510ee88d | 245 | if(tm.date<1) |
Jepalacioh | 0:c2ed510ee88d | 246 | { |
Jepalacioh | 0:c2ed510ee88d | 247 | tm.date=1; |
Jepalacioh | 0:c2ed510ee88d | 248 | } |
Jepalacioh | 0:c2ed510ee88d | 249 | |
Jepalacioh | 0:c2ed510ee88d | 250 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 251 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 252 | } |
Jepalacioh | 0:c2ed510ee88d | 253 | lcd.locate(5,0); |
jufzapataov | 2:36ae76508d25 | 254 | lcd.printf("%02d ",tm.date); |
Jepalacioh | 0:c2ed510ee88d | 255 | |
Jepalacioh | 0:c2ed510ee88d | 256 | if (button_enco.falling()) |
Jepalacioh | 0:c2ed510ee88d | 257 | { |
Jepalacioh | 0:c2ed510ee88d | 258 | i++; |
Jepalacioh | 0:c2ed510ee88d | 259 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 260 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 261 | lcd.locate(0,0); |
Jepalacioh | 0:c2ed510ee88d | 262 | lcd.printf("Mes: "); |
jufzapataov | 2:36ae76508d25 | 263 | |
Jepalacioh | 0:c2ed510ee88d | 264 | } |
Jepalacioh | 0:c2ed510ee88d | 265 | break; |
jufzapataov | 2:36ae76508d25 | 266 | case 3: // mes |
Jepalacioh | 0:c2ed510ee88d | 267 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 268 | if (m!=0) |
Jepalacioh | 0:c2ed510ee88d | 269 | { |
Jepalacioh | 0:c2ed510ee88d | 270 | tm.mon=tm.mon+m; |
Jepalacioh | 0:c2ed510ee88d | 271 | if(tm.mon>12) |
Jepalacioh | 0:c2ed510ee88d | 272 | { |
Jepalacioh | 0:c2ed510ee88d | 273 | tm.mon=12; |
Jepalacioh | 0:c2ed510ee88d | 274 | } |
Jepalacioh | 0:c2ed510ee88d | 275 | if(tm.mon<1) |
Jepalacioh | 0:c2ed510ee88d | 276 | { |
Jepalacioh | 0:c2ed510ee88d | 277 | tm.mon=1; |
Jepalacioh | 0:c2ed510ee88d | 278 | } |
Jepalacioh | 0:c2ed510ee88d | 279 | |
Jepalacioh | 0:c2ed510ee88d | 280 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 281 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 282 | } |
jufzapataov | 2:36ae76508d25 | 283 | lcd.locate(7,0); |
Jepalacioh | 0:c2ed510ee88d | 284 | lcd.printf("%02d",tm.mon); |
Jepalacioh | 0:c2ed510ee88d | 285 | |
Jepalacioh | 0:c2ed510ee88d | 286 | if (button_enco.falling()) |
Jepalacioh | 0:c2ed510ee88d | 287 | { |
Jepalacioh | 0:c2ed510ee88d | 288 | i++; |
Jepalacioh | 0:c2ed510ee88d | 289 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 290 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 291 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 292 | lcd.printf("year: "); |
tony63 | 1:0639f31dd59f | 293 | |
Jepalacioh | 0:c2ed510ee88d | 294 | } |
Jepalacioh | 0:c2ed510ee88d | 295 | |
Jepalacioh | 0:c2ed510ee88d | 296 | break; |
Jepalacioh | 0:c2ed510ee88d | 297 | |
jufzapataov | 2:36ae76508d25 | 298 | case 4: //año |
Jepalacioh | 0:c2ed510ee88d | 299 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 300 | if (m!=0) |
Jepalacioh | 0:c2ed510ee88d | 301 | { |
Jepalacioh | 0:c2ed510ee88d | 302 | tm.year=tm.year+m; |
Jepalacioh | 0:c2ed510ee88d | 303 | |
Jepalacioh | 0:c2ed510ee88d | 304 | if(tm.year<2000) |
Jepalacioh | 0:c2ed510ee88d | 305 | { |
Jepalacioh | 0:c2ed510ee88d | 306 | tm.year=2000; |
Jepalacioh | 0:c2ed510ee88d | 307 | } |
Jepalacioh | 0:c2ed510ee88d | 308 | |
Jepalacioh | 0:c2ed510ee88d | 309 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 310 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 311 | } |
Jepalacioh | 0:c2ed510ee88d | 312 | lcd.locate(6,0); |
Jepalacioh | 0:c2ed510ee88d | 313 | lcd.printf("%02d",tm.year); |
Jepalacioh | 0:c2ed510ee88d | 314 | |
Jepalacioh | 0:c2ed510ee88d | 315 | if (button_enco.falling()) |
Jepalacioh | 0:c2ed510ee88d | 316 | { |
jufzapataov | 2:36ae76508d25 | 317 | i=5; |
Jepalacioh | 0:c2ed510ee88d | 318 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 319 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 320 | lcd.locate(0,0); |
Jepalacioh | 0:c2ed510ee88d | 321 | lcd.printf("Hora: "); |
tony63 | 1:0639f31dd59f | 322 | |
jufzapataov | 2:36ae76508d25 | 323 | |
Jepalacioh | 0:c2ed510ee88d | 324 | } |
Jepalacioh | 0:c2ed510ee88d | 325 | |
Jepalacioh | 0:c2ed510ee88d | 326 | break; |
Jepalacioh | 0:c2ed510ee88d | 327 | |
jufzapataov | 2:36ae76508d25 | 328 | case 5: //HOUR |
jufzapataov | 2:36ae76508d25 | 329 | m=0; |
jufzapataov | 2:36ae76508d25 | 330 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 331 | if (m!=0) |
Jepalacioh | 0:c2ed510ee88d | 332 | { |
jufzapataov | 2:36ae76508d25 | 333 | tm.hour+= m; |
Jepalacioh | 0:c2ed510ee88d | 334 | if(tm.hour>23) |
Jepalacioh | 0:c2ed510ee88d | 335 | { |
Jepalacioh | 0:c2ed510ee88d | 336 | tm.hour=23; |
Jepalacioh | 0:c2ed510ee88d | 337 | } |
Jepalacioh | 0:c2ed510ee88d | 338 | if(tm.hour<0) |
Jepalacioh | 0:c2ed510ee88d | 339 | { |
Jepalacioh | 0:c2ed510ee88d | 340 | tm.hour=0; |
Jepalacioh | 0:c2ed510ee88d | 341 | } |
Jepalacioh | 0:c2ed510ee88d | 342 | |
Jepalacioh | 0:c2ed510ee88d | 343 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 344 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 345 | } |
Jepalacioh | 0:c2ed510ee88d | 346 | lcd.locate(6,0); |
Jepalacioh | 0:c2ed510ee88d | 347 | lcd.printf("%02d",tm.hour); |
Jepalacioh | 0:c2ed510ee88d | 348 | |
Jepalacioh | 0:c2ed510ee88d | 349 | if (button_enco.falling()) |
Jepalacioh | 0:c2ed510ee88d | 350 | { |
jufzapataov | 2:36ae76508d25 | 351 | i=6; |
Jepalacioh | 0:c2ed510ee88d | 352 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 353 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 354 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 355 | lcd.printf("Minutos: "); |
Jepalacioh | 0:c2ed510ee88d | 356 | //tm.min=0; |
Jepalacioh | 0:c2ed510ee88d | 357 | } |
Jepalacioh | 0:c2ed510ee88d | 358 | |
Jepalacioh | 0:c2ed510ee88d | 359 | break; |
Jepalacioh | 0:c2ed510ee88d | 360 | |
jufzapataov | 2:36ae76508d25 | 361 | case 6: //MINUTOS |
jufzapataov | 2:36ae76508d25 | 362 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 363 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 364 | if (m!=0) |
Jepalacioh | 0:c2ed510ee88d | 365 | { |
Jepalacioh | 0:c2ed510ee88d | 366 | tm.min=tm.min+m; |
Jepalacioh | 0:c2ed510ee88d | 367 | if(tm.min>59) |
Jepalacioh | 0:c2ed510ee88d | 368 | { |
Jepalacioh | 0:c2ed510ee88d | 369 | tm.min=59; |
Jepalacioh | 0:c2ed510ee88d | 370 | } |
Jepalacioh | 0:c2ed510ee88d | 371 | if(tm.min<0) |
Jepalacioh | 0:c2ed510ee88d | 372 | { |
Jepalacioh | 0:c2ed510ee88d | 373 | tm.min=0; |
Jepalacioh | 0:c2ed510ee88d | 374 | } |
Jepalacioh | 0:c2ed510ee88d | 375 | |
Jepalacioh | 0:c2ed510ee88d | 376 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 377 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 378 | } |
Jepalacioh | 0:c2ed510ee88d | 379 | lcd.locate(8,0); |
Jepalacioh | 0:c2ed510ee88d | 380 | lcd.printf("%02d",tm.min); |
Jepalacioh | 0:c2ed510ee88d | 381 | |
Jepalacioh | 0:c2ed510ee88d | 382 | if (button_enco.falling()) |
Jepalacioh | 0:c2ed510ee88d | 383 | { |
jufzapataov | 2:36ae76508d25 | 384 | i=7; |
Jepalacioh | 0:c2ed510ee88d | 385 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 386 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 387 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 388 | lcd.printf("Segundos: "); |
Jepalacioh | 0:c2ed510ee88d | 389 | //tm.sec=0; |
Jepalacioh | 0:c2ed510ee88d | 390 | } |
Jepalacioh | 0:c2ed510ee88d | 391 | |
Jepalacioh | 0:c2ed510ee88d | 392 | break; |
Jepalacioh | 0:c2ed510ee88d | 393 | |
Jepalacioh | 0:c2ed510ee88d | 394 | |
jufzapataov | 2:36ae76508d25 | 395 | case 7: //SEGUNDOS |
Jepalacioh | 0:c2ed510ee88d | 396 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 397 | if (m!=0) |
Jepalacioh | 0:c2ed510ee88d | 398 | { |
Jepalacioh | 0:c2ed510ee88d | 399 | tm.sec=tm.sec+m; |
Jepalacioh | 0:c2ed510ee88d | 400 | if(tm.sec>59) |
Jepalacioh | 0:c2ed510ee88d | 401 | { |
Jepalacioh | 0:c2ed510ee88d | 402 | tm.sec=59; |
Jepalacioh | 0:c2ed510ee88d | 403 | } |
Jepalacioh | 0:c2ed510ee88d | 404 | if(tm.sec<0) |
Jepalacioh | 0:c2ed510ee88d | 405 | { |
Jepalacioh | 0:c2ed510ee88d | 406 | tm.sec=0; |
Jepalacioh | 0:c2ed510ee88d | 407 | } |
Jepalacioh | 0:c2ed510ee88d | 408 | |
Jepalacioh | 0:c2ed510ee88d | 409 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 410 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 411 | } |
jufzapataov | 2:36ae76508d25 | 412 | lcd.locate(8,0); |
Jepalacioh | 0:c2ed510ee88d | 413 | lcd.printf("%02d",tm.sec); |
Jepalacioh | 0:c2ed510ee88d | 414 | |
Jepalacioh | 0:c2ed510ee88d | 415 | if (button_enco.falling()) |
Jepalacioh | 0:c2ed510ee88d | 416 | { |
jufzapataov | 2:36ae76508d25 | 417 | |
jufzapataov | 2:36ae76508d25 | 418 | |
Jepalacioh | 0:c2ed510ee88d | 419 | if(Conf==0) |
Jepalacioh | 0:c2ed510ee88d | 420 | { |
jufzapataov | 2:36ae76508d25 | 421 | Alarmas[j]=tm; |
Jepalacioh | 0:c2ed510ee88d | 422 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 423 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 424 | lcd.printf("Alarma %d config. ",j); |
Jepalacioh | 0:c2ed510ee88d | 425 | wait(1); |
Jepalacioh | 0:c2ed510ee88d | 426 | i=0; |
Jepalacioh | 0:c2ed510ee88d | 427 | m=0; |
jufzapataov | 2:36ae76508d25 | 428 | if(j>=7) |
jufzapataov | 2:36ae76508d25 | 429 | { |
Jepalacioh | 0:c2ed510ee88d | 430 | Lugar++; |
jufzapataov | 2:36ae76508d25 | 431 | } |
jufzapataov | 2:36ae76508d25 | 432 | j++; |
Jepalacioh | 0:c2ed510ee88d | 433 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 434 | |
Jepalacioh | 0:c2ed510ee88d | 435 | } |
Jepalacioh | 0:c2ed510ee88d | 436 | |
Jepalacioh | 0:c2ed510ee88d | 437 | if(Conf==1) |
jufzapataov | 2:36ae76508d25 | 438 | { |
jufzapataov | 2:36ae76508d25 | 439 | rtc.setTime(tm, true, false); |
Jepalacioh | 0:c2ed510ee88d | 440 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 441 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 442 | lcd.printf("Hora config. "); |
Jepalacioh | 0:c2ed510ee88d | 443 | wait(1); |
Jepalacioh | 0:c2ed510ee88d | 444 | i=0; |
Jepalacioh | 0:c2ed510ee88d | 445 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 446 | Lugar=0; |
Jepalacioh | 0:c2ed510ee88d | 447 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 448 | lcd.printf("--Alarmas --Hora"); |
Jepalacioh | 0:c2ed510ee88d | 449 | } |
Jepalacioh | 0:c2ed510ee88d | 450 | |
jufzapataov | 2:36ae76508d25 | 451 | |
Jepalacioh | 0:c2ed510ee88d | 452 | } |
Jepalacioh | 0:c2ed510ee88d | 453 | |
Jepalacioh | 0:c2ed510ee88d | 454 | break; |
Jepalacioh | 0:c2ed510ee88d | 455 | |
Jepalacioh | 0:c2ed510ee88d | 456 | } |
Jepalacioh | 0:c2ed510ee88d | 457 | break; |
Jepalacioh | 0:c2ed510ee88d | 458 | |
jufzapataov | 2:36ae76508d25 | 459 | case 2: // MOSTRAR EL TIEMPO Y LA ALARMA, Y COMPROBAMOS ESTADO DE LA ALARMA |
jufzapataov | 2:36ae76508d25 | 460 | rtc.getTime(tm2); //LECTURA RTC |
jufzapataov | 2:36ae76508d25 | 461 | |
Jepalacioh | 0:c2ed510ee88d | 462 | |
Jepalacioh | 0:c2ed510ee88d | 463 | if(visual==0) |
jufzapataov | 2:36ae76508d25 | 464 | { |
Jepalacioh | 0:c2ed510ee88d | 465 | lcd.locate(0,0); |
Jepalacioh | 0:c2ed510ee88d | 466 | lcd.printf("Hora: "); |
Jepalacioh | 0:c2ed510ee88d | 467 | lcd.locate(8,0); |
jufzapataov | 2:36ae76508d25 | 468 | lcd.printf("%02d:",tm2.hour); |
jufzapataov | 2:36ae76508d25 | 469 | lcd.printf("%02d:",tm2.min); |
jufzapataov | 2:36ae76508d25 | 470 | lcd.printf("%02d",tm2.sec); |
Jepalacioh | 0:c2ed510ee88d | 471 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 472 | switch(tm2.wday){ |
jufzapataov | 2:36ae76508d25 | 473 | case (1): |
jufzapataov | 2:36ae76508d25 | 474 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 475 | lcd.printf("Dom "); |
jufzapataov | 2:36ae76508d25 | 476 | break; |
jufzapataov | 2:36ae76508d25 | 477 | case (2): |
jufzapataov | 2:36ae76508d25 | 478 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 479 | lcd.printf("Lun "); |
jufzapataov | 2:36ae76508d25 | 480 | break; |
jufzapataov | 2:36ae76508d25 | 481 | case (3): |
jufzapataov | 2:36ae76508d25 | 482 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 483 | lcd.printf("Mar "); |
jufzapataov | 2:36ae76508d25 | 484 | break; |
jufzapataov | 2:36ae76508d25 | 485 | case (4): |
jufzapataov | 2:36ae76508d25 | 486 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 487 | lcd.printf("Mie "); |
jufzapataov | 2:36ae76508d25 | 488 | break; |
jufzapataov | 2:36ae76508d25 | 489 | case (5): |
jufzapataov | 2:36ae76508d25 | 490 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 491 | lcd.printf("Jue "); |
jufzapataov | 2:36ae76508d25 | 492 | break; |
jufzapataov | 2:36ae76508d25 | 493 | case (6): |
jufzapataov | 2:36ae76508d25 | 494 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 495 | lcd.printf("Vie "); |
jufzapataov | 2:36ae76508d25 | 496 | break; |
jufzapataov | 2:36ae76508d25 | 497 | case (7): |
jufzapataov | 2:36ae76508d25 | 498 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 499 | lcd.printf("Sab "); |
jufzapataov | 2:36ae76508d25 | 500 | break; |
jufzapataov | 2:36ae76508d25 | 501 | } |
jufzapataov | 2:36ae76508d25 | 502 | lcd.locate(6,1); |
jufzapataov | 2:36ae76508d25 | 503 | lcd.printf("%02d/",tm2.date); |
jufzapataov | 2:36ae76508d25 | 504 | lcd.printf("%02d/",tm2.mon); |
jufzapataov | 2:36ae76508d25 | 505 | lcd.printf("%02d",tm2.year); |
Jepalacioh | 0:c2ed510ee88d | 506 | wait(0.1); |
Jepalacioh | 0:c2ed510ee88d | 507 | ////////// |
Jepalacioh | 0:c2ed510ee88d | 508 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 509 | if(m!=0) |
Jepalacioh | 0:c2ed510ee88d | 510 | { |
Jepalacioh | 0:c2ed510ee88d | 511 | visual=1; |
Jepalacioh | 0:c2ed510ee88d | 512 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 513 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 514 | } |
Jepalacioh | 0:c2ed510ee88d | 515 | } |
Jepalacioh | 0:c2ed510ee88d | 516 | |
Jepalacioh | 0:c2ed510ee88d | 517 | if(visual==1) |
Jepalacioh | 0:c2ed510ee88d | 518 | { |
jufzapataov | 2:36ae76508d25 | 519 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 520 | lcd.printf(" "); |
Jepalacioh | 0:c2ed510ee88d | 521 | lcd.locate(8,0); |
jufzapataov | 2:36ae76508d25 | 522 | lcd.printf("%02d:",Alarmas[irda].hour); |
jufzapataov | 2:36ae76508d25 | 523 | lcd.printf("%02d:",Alarmas[irda].min); |
jufzapataov | 2:36ae76508d25 | 524 | lcd.printf("%02d",Alarmas[irda].sec); |
Jepalacioh | 0:c2ed510ee88d | 525 | |
jufzapataov | 2:36ae76508d25 | 526 | switch(Alarmas[irda].wday){ |
jufzapataov | 2:36ae76508d25 | 527 | case (1): |
jufzapataov | 2:36ae76508d25 | 528 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 529 | lcd.printf("Dom "); |
jufzapataov | 2:36ae76508d25 | 530 | break; |
jufzapataov | 2:36ae76508d25 | 531 | case (2): |
jufzapataov | 2:36ae76508d25 | 532 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 533 | lcd.printf("Lun "); |
jufzapataov | 2:36ae76508d25 | 534 | break; |
jufzapataov | 2:36ae76508d25 | 535 | case (3): |
jufzapataov | 2:36ae76508d25 | 536 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 537 | lcd.printf("Mar "); |
jufzapataov | 2:36ae76508d25 | 538 | break; |
jufzapataov | 2:36ae76508d25 | 539 | case (4): |
jufzapataov | 2:36ae76508d25 | 540 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 541 | lcd.printf("Mie "); |
jufzapataov | 2:36ae76508d25 | 542 | break; |
jufzapataov | 2:36ae76508d25 | 543 | case (5): |
jufzapataov | 2:36ae76508d25 | 544 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 545 | lcd.printf("Jue "); |
jufzapataov | 2:36ae76508d25 | 546 | break; |
jufzapataov | 2:36ae76508d25 | 547 | case (6): |
jufzapataov | 2:36ae76508d25 | 548 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 549 | lcd.printf("Vie "); |
jufzapataov | 2:36ae76508d25 | 550 | break; |
jufzapataov | 2:36ae76508d25 | 551 | case (7): |
jufzapataov | 2:36ae76508d25 | 552 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 553 | lcd.printf("Sab "); |
jufzapataov | 2:36ae76508d25 | 554 | break; |
jufzapataov | 2:36ae76508d25 | 555 | } |
jufzapataov | 2:36ae76508d25 | 556 | lcd.locate(4,1); |
jufzapataov | 2:36ae76508d25 | 557 | lcd.printf("Alarma %d Set",irda); |
Jepalacioh | 0:c2ed510ee88d | 558 | wait(0.1); |
Jepalacioh | 0:c2ed510ee88d | 559 | //// |
Jepalacioh | 0:c2ed510ee88d | 560 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 561 | if(m!=0) |
Jepalacioh | 0:c2ed510ee88d | 562 | { |
Jepalacioh | 0:c2ed510ee88d | 563 | visual=0; |
Jepalacioh | 0:c2ed510ee88d | 564 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 565 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 566 | } |
Jepalacioh | 0:c2ed510ee88d | 567 | } |
jufzapataov | 2:36ae76508d25 | 568 | |
jufzapataov | 2:36ae76508d25 | 569 | /// COMPROBACION ALARMA |
jufzapataov | 2:36ae76508d25 | 570 | if( (tm2.wday==Alarmas[irda].wday)&&((tm2.hour)==Alarmas[irda].hour)&&(tm2.min==Alarmas[irda].min)&&(tm2.sec==Alarmas[irda].sec) ) |
Jepalacioh | 0:c2ed510ee88d | 571 | { |
Jepalacioh | 0:c2ed510ee88d | 572 | Lugar++; |
Jepalacioh | 0:c2ed510ee88d | 573 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 574 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 575 | lcd.printf("Alarma activada!!!"); |
Jepalacioh | 0:c2ed510ee88d | 576 | wait(1); |
Jepalacioh | 0:c2ed510ee88d | 577 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 578 | lcd.printf("->Apagar "); |
Jepalacioh | 0:c2ed510ee88d | 579 | lcd.locate(0,1); |
jufzapataov | 2:36ae76508d25 | 580 | lcd.printf("--Aplazar "); |
Jepalacioh | 0:c2ed510ee88d | 581 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 582 | } |
jufzapataov | 2:36ae76508d25 | 583 | |
jufzapataov | 2:36ae76508d25 | 584 | // esperando IRDA |
jufzapataov | 2:36ae76508d25 | 585 | if (button_enco.falling()) |
jufzapataov | 2:36ae76508d25 | 586 | { |
jufzapataov | 2:36ae76508d25 | 587 | sensor_en=1; |
jufzapataov | 2:36ae76508d25 | 588 | lcd.cls(); |
jufzapataov | 2:36ae76508d25 | 589 | lcd.locate(0,0); |
jufzapataov | 2:36ae76508d25 | 590 | lcd.printf(" Esperando IRDA "); |
jufzapataov | 2:36ae76508d25 | 591 | |
jufzapataov | 2:36ae76508d25 | 592 | } |
Jepalacioh | 0:c2ed510ee88d | 593 | |
Jepalacioh | 0:c2ed510ee88d | 594 | break; |
Jepalacioh | 0:c2ed510ee88d | 595 | |
jufzapataov | 2:36ae76508d25 | 596 | case 3: //Apagar o Aplazar |
Jepalacioh | 0:c2ed510ee88d | 597 | |
jufzapataov | 2:36ae76508d25 | 598 | if(alarma==0) //Aplazar |
Jepalacioh | 0:c2ed510ee88d | 599 | { |
jufzapataov | 2:36ae76508d25 | 600 | myled=1; |
jufzapataov | 2:36ae76508d25 | 601 | wait(0.5); |
jufzapataov | 2:36ae76508d25 | 602 | myled=0; |
jufzapataov | 2:36ae76508d25 | 603 | wait(0.5); |
jufzapataov | 2:36ae76508d25 | 604 | |
Jepalacioh | 0:c2ed510ee88d | 605 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 606 | if(m!=0) |
Jepalacioh | 0:c2ed510ee88d | 607 | { |
Jepalacioh | 0:c2ed510ee88d | 608 | alarma=1; |
Jepalacioh | 0:c2ed510ee88d | 609 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 610 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 611 | |
Jepalacioh | 0:c2ed510ee88d | 612 | lcd.locate(1,0); |
Jepalacioh | 0:c2ed510ee88d | 613 | lcd.printf("-"); |
Jepalacioh | 0:c2ed510ee88d | 614 | lcd.locate(1,1); |
Jepalacioh | 0:c2ed510ee88d | 615 | lcd.printf(">"); |
Jepalacioh | 0:c2ed510ee88d | 616 | } |
Jepalacioh | 0:c2ed510ee88d | 617 | } |
Jepalacioh | 0:c2ed510ee88d | 618 | |
Jepalacioh | 0:c2ed510ee88d | 619 | /////////////////// |
Jepalacioh | 0:c2ed510ee88d | 620 | |
jufzapataov | 2:36ae76508d25 | 621 | if(alarma==1) //Apagar |
Jepalacioh | 0:c2ed510ee88d | 622 | { |
jufzapataov | 2:36ae76508d25 | 623 | myled=1; |
jufzapataov | 2:36ae76508d25 | 624 | wait(0.5); |
jufzapataov | 2:36ae76508d25 | 625 | myled=0; |
jufzapataov | 2:36ae76508d25 | 626 | wait(0.5); |
jufzapataov | 2:36ae76508d25 | 627 | |
Jepalacioh | 0:c2ed510ee88d | 628 | m=wheel.getPulses(); |
Jepalacioh | 0:c2ed510ee88d | 629 | if(m!=0) |
Jepalacioh | 0:c2ed510ee88d | 630 | { |
Jepalacioh | 0:c2ed510ee88d | 631 | alarma=0; |
Jepalacioh | 0:c2ed510ee88d | 632 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 633 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 634 | |
Jepalacioh | 0:c2ed510ee88d | 635 | lcd.locate(1,0); |
Jepalacioh | 0:c2ed510ee88d | 636 | lcd.printf(">"); |
Jepalacioh | 0:c2ed510ee88d | 637 | lcd.locate(1,1); |
Jepalacioh | 0:c2ed510ee88d | 638 | lcd.printf("-"); |
Jepalacioh | 0:c2ed510ee88d | 639 | } |
Jepalacioh | 0:c2ed510ee88d | 640 | } |
Jepalacioh | 0:c2ed510ee88d | 641 | |
Jepalacioh | 0:c2ed510ee88d | 642 | if (button_enco.falling()) |
Jepalacioh | 0:c2ed510ee88d | 643 | { |
Jepalacioh | 0:c2ed510ee88d | 644 | if(alarma==0) |
Jepalacioh | 0:c2ed510ee88d | 645 | { |
jufzapataov | 2:36ae76508d25 | 646 | Lugar=2; //regresa a mostrar la hora |
Jepalacioh | 0:c2ed510ee88d | 647 | wheel.reset(); |
Jepalacioh | 0:c2ed510ee88d | 648 | m=0; |
jufzapataov | 2:36ae76508d25 | 649 | myled=1; |
jufzapataov | 2:36ae76508d25 | 650 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 651 | } |
Jepalacioh | 0:c2ed510ee88d | 652 | if(alarma==1) |
Jepalacioh | 0:c2ed510ee88d | 653 | { |
jufzapataov | 2:36ae76508d25 | 654 | Lugar=2; //regresa a mostrar el tiempo con la alarma actual |
jufzapataov | 2:36ae76508d25 | 655 | rtc.getTime(tm2); |
Jepalacioh | 0:c2ed510ee88d | 656 | if(tm.min!=58) |
Jepalacioh | 0:c2ed510ee88d | 657 | { |
jufzapataov | 2:36ae76508d25 | 658 | Alarmas[irda].min=tm2.min+1; |
Jepalacioh | 0:c2ed510ee88d | 659 | } |
Jepalacioh | 0:c2ed510ee88d | 660 | if(tm.min==59) |
Jepalacioh | 0:c2ed510ee88d | 661 | { |
jufzapataov | 2:36ae76508d25 | 662 | Alarmas[irda].min=0; |
jufzapataov | 2:36ae76508d25 | 663 | Alarmas[irda].hour=tm2.hour+1; |
Jepalacioh | 0:c2ed510ee88d | 664 | } |
jufzapataov | 2:36ae76508d25 | 665 | Alarmas[irda].sec=tm2.sec; |
Jepalacioh | 0:c2ed510ee88d | 666 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 667 | alarma=0; |
jufzapataov | 2:36ae76508d25 | 668 | myled=1; |
jufzapataov | 2:36ae76508d25 | 669 | } |
Jepalacioh | 0:c2ed510ee88d | 670 | } |
Jepalacioh | 0:c2ed510ee88d | 671 | break; |
jufzapataov | 2:36ae76508d25 | 672 | } |
jufzapataov | 2:36ae76508d25 | 673 | |
jufzapataov | 2:36ae76508d25 | 674 | |
jufzapataov | 2:36ae76508d25 | 675 | // lee el irda |
jufzapataov | 2:36ae76508d25 | 676 | while (sensor_en) |
jufzapataov | 2:36ae76508d25 | 677 | { |
jufzapataov | 2:36ae76508d25 | 678 | fflush( stdin ); |
jufzapataov | 2:36ae76508d25 | 679 | lop2: if(!mode){ |
jufzapataov | 2:36ae76508d25 | 680 | header = sensor.read_high_us(); |
jufzapataov | 2:36ae76508d25 | 681 | if(header>4000) goto seguir2; |
jufzapataov | 2:36ae76508d25 | 682 | goto lop2; |
jufzapataov | 2:36ae76508d25 | 683 | } |
jufzapataov | 2:36ae76508d25 | 684 | |
jufzapataov | 2:36ae76508d25 | 685 | seguir2: |
jufzapataov | 2:36ae76508d25 | 686 | for(i1=0;i1<numb;++i1){ |
jufzapataov | 2:36ae76508d25 | 687 | P[i1] = sensor.read_high_us(); //funcion para leer un pulso alto |
jufzapataov | 2:36ae76508d25 | 688 | if (P[i1]<1500){ |
jufzapataov | 2:36ae76508d25 | 689 | s=0; |
jufzapataov | 2:36ae76508d25 | 690 | r='0'; |
jufzapataov | 2:36ae76508d25 | 691 | }else{ |
jufzapataov | 2:36ae76508d25 | 692 | s=1; |
jufzapataov | 2:36ae76508d25 | 693 | r='1'; |
jufzapataov | 2:36ae76508d25 | 694 | } |
jufzapataov | 2:36ae76508d25 | 695 | bin[i1]=s; |
jufzapataov | 2:36ae76508d25 | 696 | stri[i1]=r; |
jufzapataov | 2:36ae76508d25 | 697 | } |
jufzapataov | 2:36ae76508d25 | 698 | pc.printf("string=%s\n",stri); |
jufzapataov | 2:36ae76508d25 | 699 | if (!strcmp(stri,Tec1)){ |
jufzapataov | 2:36ae76508d25 | 700 | irda=1; |
jufzapataov | 2:36ae76508d25 | 701 | lcd.locate(8,1); |
jufzapataov | 2:36ae76508d25 | 702 | lcd.printf("%d",irda); |
jufzapataov | 2:36ae76508d25 | 703 | goto seguir2; |
jufzapataov | 2:36ae76508d25 | 704 | }else if (!strcmp(stri,Tec2)){ |
jufzapataov | 2:36ae76508d25 | 705 | irda=2; |
jufzapataov | 2:36ae76508d25 | 706 | lcd.locate(8,1); |
jufzapataov | 2:36ae76508d25 | 707 | lcd.printf("%d",stri); |
jufzapataov | 2:36ae76508d25 | 708 | goto seguir2; |
jufzapataov | 2:36ae76508d25 | 709 | }else if (!strcmp(stri,Tec3)){ |
jufzapataov | 2:36ae76508d25 | 710 | irda=3; |
jufzapataov | 2:36ae76508d25 | 711 | lcd.locate(8,1); |
jufzapataov | 2:36ae76508d25 | 712 | lcd.printf("%d",irda); |
jufzapataov | 2:36ae76508d25 | 713 | goto seguir2; |
jufzapataov | 2:36ae76508d25 | 714 | }else if (!strcmp(stri,Tec4)){ |
jufzapataov | 2:36ae76508d25 | 715 | irda=4; |
jufzapataov | 2:36ae76508d25 | 716 | lcd.locate(8,1); |
jufzapataov | 2:36ae76508d25 | 717 | lcd.printf("%d",irda); |
jufzapataov | 2:36ae76508d25 | 718 | goto seguir2; |
jufzapataov | 2:36ae76508d25 | 719 | }else if (!strcmp(stri,Tec5)){ |
jufzapataov | 2:36ae76508d25 | 720 | irda=5; |
jufzapataov | 2:36ae76508d25 | 721 | lcd.locate(8,1); |
jufzapataov | 2:36ae76508d25 | 722 | lcd.printf("%d",irda); |
jufzapataov | 2:36ae76508d25 | 723 | goto seguir2; |
jufzapataov | 2:36ae76508d25 | 724 | }else if (!strcmp(stri,Tec6)){ |
jufzapataov | 2:36ae76508d25 | 725 | irda=6; |
jufzapataov | 2:36ae76508d25 | 726 | lcd.locate(8,1); |
jufzapataov | 2:36ae76508d25 | 727 | lcd.printf("%d",irda); |
jufzapataov | 2:36ae76508d25 | 728 | goto seguir2; |
jufzapataov | 2:36ae76508d25 | 729 | }else if (!strcmp(stri,Tec7)){ |
jufzapataov | 2:36ae76508d25 | 730 | irda=7; |
jufzapataov | 2:36ae76508d25 | 731 | lcd.locate(8,1); |
jufzapataov | 2:36ae76508d25 | 732 | lcd.printf("%d",irda); |
jufzapataov | 2:36ae76508d25 | 733 | goto seguir2; |
jufzapataov | 2:36ae76508d25 | 734 | }else if(!strcmp(stri,TecSet)){ |
jufzapataov | 2:36ae76508d25 | 735 | goto lop3; |
jufzapataov | 2:36ae76508d25 | 736 | } |
jufzapataov | 2:36ae76508d25 | 737 | lop3: Lugar=2; |
jufzapataov | 2:36ae76508d25 | 738 | sensor_en=0; |
jufzapataov | 2:36ae76508d25 | 739 | lcd.cls(); |
jufzapataov | 2:36ae76508d25 | 740 | break; |
jufzapataov | 2:36ae76508d25 | 741 | } |
jufzapataov | 2:36ae76508d25 | 742 | } |
Jepalacioh | 0:c2ed510ee88d | 743 | } |