Procesadores, 2016 - II. Tarea #2. Oswaldo Andrés Giraldo Giraldo, Héctor Andrés Hoyos Ceballos, Jose Fernando Montoya Vargas, María Fernanda Villa Tamayo. Programa para establecer alarmas con ayuda del reloj DS1307 por comunicación I2C.
Dependencies: Debounced QEI RTC-DS1307 TextLCD mbed
Fork of Reloj_alarma by
main.cpp@2:cb1f588caed7, 2016-11-16 (annotated)
- Committer:
- joshema216
- Date:
- Wed Nov 16 02:22:17 2016 +0000
- Revision:
- 2:cb1f588caed7
- Parent:
- 1:0639f31dd59f
Version 1.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joshema216 | 2:cb1f588caed7 | 1 | // Programa para configurar 4 alarmas con el reloj DS1307 por comunicación I2C. Se configurarán los tiempos de |
joshema216 | 2:cb1f588caed7 | 2 | // encendido y apagado de cada una de las alarmas y la acción de las mismas se verá representada por el estado |
joshema216 | 2:cb1f588caed7 | 3 | // de un LED para cada una (cuando se active una alarma se deberá encender, cuando se desactive se deberá de |
joshema216 | 2:cb1f588caed7 | 4 | // apagar), por lo que las alarmas son independientes. Luego, se deberá estar comparando constantemente el |
joshema216 | 2:cb1f588caed7 | 5 | // tiempo actual con cada una de las alarmas por a parte. |
joshema216 | 2:cb1f588caed7 | 6 | |
joshema216 | 2:cb1f588caed7 | 7 | // Oswaldo Andrés Giraldo Giraldo - C.C.: 1152458465 |
joshema216 | 2:cb1f588caed7 | 8 | // Héctor Andrés Hoyos Ceballos - C.C.: 1039466317 |
joshema216 | 2:cb1f588caed7 | 9 | // Jose Fernando Montoya Vargas - C.C.: 1039468676 |
joshema216 | 2:cb1f588caed7 | 10 | // María Fernanda Villa Tamayo - C.C.: 1152457490 |
joshema216 | 2:cb1f588caed7 | 11 | |
Jepalacioh | 0:c2ed510ee88d | 12 | #include "mbed.h" |
joshema216 | 2:cb1f588caed7 | 13 | #include "DebouncedIn.h" // Librería para los botones. |
Jepalacioh | 0:c2ed510ee88d | 14 | #include "TextLCD.h" |
Jepalacioh | 0:c2ed510ee88d | 15 | #include "QEI.h" |
Jepalacioh | 0:c2ed510ee88d | 16 | #include "Rtc_Ds1307.h" |
Jepalacioh | 0:c2ed510ee88d | 17 | |
joshema216 | 2:cb1f588caed7 | 18 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // RS, E, D4 - D7 |
joshema216 | 2:cb1f588caed7 | 19 | Rtc_Ds1307 rtc(PTE0, PTE1); // Configura el reloj. |
joshema216 | 2:cb1f588caed7 | 20 | QEI wheel (PTA13, PTD5, NC, 48); // Configura el encoder. |
joshema216 | 2:cb1f588caed7 | 21 | DebouncedIn button_enco(PTC16); // Configura el botón del encoder. |
joshema216 | 2:cb1f588caed7 | 22 | |
joshema216 | 2:cb1f588caed7 | 23 | DigitalOut ALED1(PTA5);// Salida del LED de la alarma 1. |
joshema216 | 2:cb1f588caed7 | 24 | DigitalOut ALED2(PTA4);// Salida del LED de la alarma 2. |
joshema216 | 2:cb1f588caed7 | 25 | DigitalOut ALED3(PTA12);// Salida del LED de la alarma 3. |
joshema216 | 2:cb1f588caed7 | 26 | DigitalOut ALED4(PTD4);// Salida del LED de la alarma 4. |
Jepalacioh | 0:c2ed510ee88d | 27 | |
joshema216 | 2:cb1f588caed7 | 28 | Serial pc(USBTX, USBRX); // TX, RX. |
Jepalacioh | 0:c2ed510ee88d | 29 | |
joshema216 | 2:cb1f588caed7 | 30 | int C1 = 0x0C; |
joshema216 | 2:cb1f588caed7 | 31 | int m; |
joshema216 | 2:cb1f588caed7 | 32 | int Conf = 0; // 0: Reloj, 1: Alarmas. |
joshema216 | 2:cb1f588caed7 | 33 | int Lugar = 0; // Definen el punto en el cual va el programa. |
joshema216 | 2:cb1f588caed7 | 34 | int i = 0, ala = 1, a1 = 0, a2 = 0, a3 = 0, a4 = 0, cont = 0; |
joshema216 | 2:cb1f588caed7 | 35 | int visual = 0; |
joshema216 | 2:cb1f588caed7 | 36 | int alarma = 0; |
Jepalacioh | 0:c2ed510ee88d | 37 | |
joshema216 | 2:cb1f588caed7 | 38 | int main(){ |
joshema216 | 2:cb1f588caed7 | 39 | Rtc_Ds1307::Time_rtc tm = {}; // Inicializa el reloj. |
joshema216 | 2:cb1f588caed7 | 40 | Rtc_Ds1307::Time_rtc A1on = {}; // Inicializa el tiempo de encendido de la alarma 1. |
joshema216 | 2:cb1f588caed7 | 41 | Rtc_Ds1307::Time_rtc A2on = {}; // Inicializa el tiempo de encendido de la alarma 2. |
joshema216 | 2:cb1f588caed7 | 42 | Rtc_Ds1307::Time_rtc A3on = {}; // Inicializa el tiempo de encendido de la alarma 3. |
joshema216 | 2:cb1f588caed7 | 43 | Rtc_Ds1307::Time_rtc A4on = {}; // Inicializa el tiempo de encendido de la alarma 4. |
joshema216 | 2:cb1f588caed7 | 44 | Rtc_Ds1307::Time_rtc A1off = {}; // Inicializa el tiempo de apagado de la alarma 1. |
joshema216 | 2:cb1f588caed7 | 45 | Rtc_Ds1307::Time_rtc A2off = {}; // Inicializa el tiempo de apagado de la alarma 2. |
joshema216 | 2:cb1f588caed7 | 46 | Rtc_Ds1307::Time_rtc A3off = {}; // Inicializa el tiempo de apagado de la alarma 3. |
joshema216 | 2:cb1f588caed7 | 47 | Rtc_Ds1307::Time_rtc A4off = {}; // Inicializa el tiempo de apagado de la alarma 4. |
joshema216 | 2:cb1f588caed7 | 48 | |
joshema216 | 2:cb1f588caed7 | 49 | lcd.cls(); // Borra la pantalla. |
joshema216 | 2:cb1f588caed7 | 50 | lcd.writeCommand(C1); // Escribimos un comando segun el manual del modulo LCD. |
joshema216 | 2:cb1f588caed7 | 51 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 52 | lcd.printf("** Reloj de"); |
joshema216 | 2:cb1f588caed7 | 53 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 54 | lcd.printf(" 4 alarmas **"); |
joshema216 | 2:cb1f588caed7 | 55 | wait(2); |
joshema216 | 2:cb1f588caed7 | 56 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 57 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 58 | lcd.printf("--Reloj"); // Sin flechas. |
joshema216 | 2:cb1f588caed7 | 59 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 60 | lcd.printf("--Alarmas"); |
joshema216 | 2:cb1f588caed7 | 61 | |
joshema216 | 2:cb1f588caed7 | 62 | rtc.getTime(tm); // Lee el tiempo del DS1307. Leyó todo el hijuemadre reloj de un golpe, hora, min, seg y lo mete en tm |
joshema216 | 2:cb1f588caed7 | 63 | |
joshema216 | 2:cb1f588caed7 | 64 | while(1){ |
Jepalacioh | 0:c2ed510ee88d | 65 | |
joshema216 | 2:cb1f588caed7 | 66 | // Etapa de menú. |
joshema216 | 2:cb1f588caed7 | 67 | if (Lugar == 0){ // Varía entre reloj y alarma. Por el boton del encoder incrementa una variable que se llama lugar. |
joshema216 | 2:cb1f588caed7 | 68 | m = wheel.getPulses(); // m son los datos del encoder. |
joshema216 | 2:cb1f588caed7 | 69 | if(m!=0 && Conf == 0){// Si se movió el encoder y está en Reloj. |
joshema216 | 2:cb1f588caed7 | 70 | Conf = 1; // Lo cambia a Alarmas. |
joshema216 | 2:cb1f588caed7 | 71 | wheel.reset(); // Si está en un estado inferior, la resetea. |
joshema216 | 2:cb1f588caed7 | 72 | m=0; |
joshema216 | 2:cb1f588caed7 | 73 | ala++; |
joshema216 | 2:cb1f588caed7 | 74 | pc.printf("%d", ala, "\n"); |
joshema216 | 2:cb1f588caed7 | 75 | } |
joshema216 | 2:cb1f588caed7 | 76 | |
joshema216 | 2:cb1f588caed7 | 77 | if(m!=0 && Conf == 1){ // Si se movió el encoder y está en Alarmas. |
joshema216 | 2:cb1f588caed7 | 78 | Conf = 0; // Lo pone en Reloj. |
joshema216 | 2:cb1f588caed7 | 79 | wheel.reset(); // Resetea. |
joshema216 | 2:cb1f588caed7 | 80 | m=0; |
joshema216 | 2:cb1f588caed7 | 81 | ala = 1; |
joshema216 | 2:cb1f588caed7 | 82 | pc.printf("%d", ala, "\n"); |
joshema216 | 2:cb1f588caed7 | 83 | } |
joshema216 | 2:cb1f588caed7 | 84 | |
joshema216 | 2:cb1f588caed7 | 85 | if(Conf == 0){ // Si la configuración cambia pone la flechita en Reloj. |
joshema216 | 2:cb1f588caed7 | 86 | |
joshema216 | 2:cb1f588caed7 | 87 | lcd.locate(1,1); |
joshema216 | 2:cb1f588caed7 | 88 | lcd.printf("-"); |
joshema216 | 2:cb1f588caed7 | 89 | lcd.locate(1,0); |
joshema216 | 2:cb1f588caed7 | 90 | lcd.printf(">"); |
joshema216 | 2:cb1f588caed7 | 91 | lcd.locate(16,1); |
joshema216 | 2:cb1f588caed7 | 92 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 93 | |
joshema216 | 2:cb1f588caed7 | 94 | } |
joshema216 | 2:cb1f588caed7 | 95 | |
joshema216 | 2:cb1f588caed7 | 96 | if(Conf == 1){ // Poner la flechita en Alarmas. |
joshema216 | 2:cb1f588caed7 | 97 | lcd.locate(1,0); |
joshema216 | 2:cb1f588caed7 | 98 | lcd.printf("-"); |
joshema216 | 2:cb1f588caed7 | 99 | lcd.locate(1,1); // Tira la flechita para abajo. |
joshema216 | 2:cb1f588caed7 | 100 | lcd.printf(">"); |
joshema216 | 2:cb1f588caed7 | 101 | lcd.locate(16,1); |
joshema216 | 2:cb1f588caed7 | 102 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 103 | } |
joshema216 | 2:cb1f588caed7 | 104 | |
joshema216 | 2:cb1f588caed7 | 105 | if (button_enco.falling()){ // Si se pulsa botón del encoder. |
joshema216 | 2:cb1f588caed7 | 106 | Lugar++; //aumenta lugar |
joshema216 | 2:cb1f588caed7 | 107 | m = 0; |
joshema216 | 2:cb1f588caed7 | 108 | pc.printf("%d", Conf, "\n"); |
joshema216 | 2:cb1f588caed7 | 109 | pc.printf("%d", ala, "\n"); |
joshema216 | 2:cb1f588caed7 | 110 | } |
joshema216 | 2:cb1f588caed7 | 111 | } |
joshema216 | 2:cb1f588caed7 | 112 | |
joshema216 | 2:cb1f588caed7 | 113 | // Etapa de llenado de variables (Reloj y Alarmas). |
joshema216 | 2:cb1f588caed7 | 114 | else if (Lugar == 1){ |
joshema216 | 2:cb1f588caed7 | 115 | if (i == 0){ |
joshema216 | 2:cb1f588caed7 | 116 | if(Conf == 0){ // Empieza a configurar el Reloj. |
joshema216 | 2:cb1f588caed7 | 117 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 118 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 119 | lcd.printf("Configurar reloj"); |
joshema216 | 2:cb1f588caed7 | 120 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 121 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 122 | i++; |
joshema216 | 2:cb1f588caed7 | 123 | m = 0; |
joshema216 | 2:cb1f588caed7 | 124 | } |
joshema216 | 2:cb1f588caed7 | 125 | |
joshema216 | 2:cb1f588caed7 | 126 | if(Conf == 1 && ala == 2){ // Empieza a configurar inicialmente la alarma 1 encendido. |
joshema216 | 2:cb1f588caed7 | 127 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 128 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 129 | lcd.printf("Config. Alarma 1"); |
joshema216 | 2:cb1f588caed7 | 130 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 131 | lcd.printf("encendido"); |
joshema216 | 2:cb1f588caed7 | 132 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 133 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 134 | i++; |
joshema216 | 2:cb1f588caed7 | 135 | m=0; |
joshema216 | 2:cb1f588caed7 | 136 | } |
joshema216 | 2:cb1f588caed7 | 137 | |
joshema216 | 2:cb1f588caed7 | 138 | if(Conf == 1 && ala == 3){ // Configurar alarma 1 apagado. |
joshema216 | 2:cb1f588caed7 | 139 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 140 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 141 | lcd.printf("Config. Alarma 1"); |
joshema216 | 2:cb1f588caed7 | 142 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 143 | lcd.printf("apagado"); |
joshema216 | 2:cb1f588caed7 | 144 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 145 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 146 | i++; |
joshema216 | 2:cb1f588caed7 | 147 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 148 | } |
Jepalacioh | 0:c2ed510ee88d | 149 | |
joshema216 | 2:cb1f588caed7 | 150 | if(Conf == 1 && ala == 4){ // Configurar alarma 3 encendido. |
joshema216 | 2:cb1f588caed7 | 151 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 152 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 153 | lcd.printf("Config. Alarma 2"); |
joshema216 | 2:cb1f588caed7 | 154 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 155 | lcd.printf("encendido"); |
joshema216 | 2:cb1f588caed7 | 156 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 157 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 158 | i++; |
joshema216 | 2:cb1f588caed7 | 159 | m=0; |
joshema216 | 2:cb1f588caed7 | 160 | } |
joshema216 | 2:cb1f588caed7 | 161 | |
joshema216 | 2:cb1f588caed7 | 162 | if(Conf == 1 && ala == 5){ // Configurar alarma 2 apagado. |
joshema216 | 2:cb1f588caed7 | 163 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 164 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 165 | lcd.printf("Config. Alarma 2"); |
joshema216 | 2:cb1f588caed7 | 166 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 167 | lcd.printf("apagado"); |
joshema216 | 2:cb1f588caed7 | 168 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 169 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 170 | i++; |
joshema216 | 2:cb1f588caed7 | 171 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 172 | } |
Jepalacioh | 0:c2ed510ee88d | 173 | |
joshema216 | 2:cb1f588caed7 | 174 | if(Conf == 1 && ala == 6){ // Configurar alarma 3 encendido. |
joshema216 | 2:cb1f588caed7 | 175 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 176 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 177 | lcd.printf("Config. Alarma 3"); |
joshema216 | 2:cb1f588caed7 | 178 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 179 | lcd.printf("encendido"); |
joshema216 | 2:cb1f588caed7 | 180 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 181 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 182 | i++; |
joshema216 | 2:cb1f588caed7 | 183 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 184 | } |
Jepalacioh | 0:c2ed510ee88d | 185 | |
joshema216 | 2:cb1f588caed7 | 186 | if(Conf == 1 && ala == 7){ // Configurar alarma 3 apagado. |
joshema216 | 2:cb1f588caed7 | 187 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 188 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 189 | lcd.printf("Config. Alarma 3"); |
joshema216 | 2:cb1f588caed7 | 190 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 191 | lcd.printf("apagado"); |
joshema216 | 2:cb1f588caed7 | 192 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 193 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 194 | i++; |
joshema216 | 2:cb1f588caed7 | 195 | m=0; |
joshema216 | 2:cb1f588caed7 | 196 | } |
joshema216 | 2:cb1f588caed7 | 197 | if(Conf == 1 && ala == 8){ // Configurar alarma 4 encendido. |
joshema216 | 2:cb1f588caed7 | 198 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 199 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 200 | lcd.printf("Config. Alarma 4"); |
joshema216 | 2:cb1f588caed7 | 201 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 202 | lcd.printf("encendido"); |
joshema216 | 2:cb1f588caed7 | 203 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 204 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 205 | i++; |
joshema216 | 2:cb1f588caed7 | 206 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 207 | } |
Jepalacioh | 0:c2ed510ee88d | 208 | |
joshema216 | 2:cb1f588caed7 | 209 | if(Conf == 1 && ala == 9){ // Configurar alarma 4 apagado. |
joshema216 | 2:cb1f588caed7 | 210 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 211 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 212 | lcd.printf("Config. Alarma 4"); |
joshema216 | 2:cb1f588caed7 | 213 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 214 | lcd.printf("apagado"); |
joshema216 | 2:cb1f588caed7 | 215 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 216 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 217 | i++; |
joshema216 | 2:cb1f588caed7 | 218 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 219 | } |
joshema216 | 2:cb1f588caed7 | 220 | } |
Jepalacioh | 0:c2ed510ee88d | 221 | |
joshema216 | 2:cb1f588caed7 | 222 | if (i == 1){ // Modificar Día. |
joshema216 | 2:cb1f588caed7 | 223 | //pc.printf("Estoy en el llenado.\n"); |
joshema216 | 2:cb1f588caed7 | 224 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 225 | if (m!=0) { |
joshema216 | 2:cb1f588caed7 | 226 | tm.date = tm.date+m; // modifica el dia, maximo en 31 y min en 1 |
joshema216 | 2:cb1f588caed7 | 227 | if(tm.date > 31){ |
joshema216 | 2:cb1f588caed7 | 228 | tm.date=1; |
joshema216 | 2:cb1f588caed7 | 229 | } |
joshema216 | 2:cb1f588caed7 | 230 | if(tm.date<1){ |
joshema216 | 2:cb1f588caed7 | 231 | tm.date=1; |
joshema216 | 2:cb1f588caed7 | 232 | } |
joshema216 | 2:cb1f588caed7 | 233 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 234 | m = 0; |
joshema216 | 2:cb1f588caed7 | 235 | } |
joshema216 | 2:cb1f588caed7 | 236 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 237 | lcd.printf("Dia: "); |
joshema216 | 2:cb1f588caed7 | 238 | lcd.locate(5,0); |
joshema216 | 2:cb1f588caed7 | 239 | lcd.printf("%02d",tm.date); |
joshema216 | 2:cb1f588caed7 | 240 | if (button_enco.falling()){ |
joshema216 | 2:cb1f588caed7 | 241 | i++; |
joshema216 | 2:cb1f588caed7 | 242 | m=0; |
joshema216 | 2:cb1f588caed7 | 243 | } |
joshema216 | 2:cb1f588caed7 | 244 | } |
joshema216 | 2:cb1f588caed7 | 245 | |
joshema216 | 2:cb1f588caed7 | 246 | else if (i == 2){ // Modificar Mes. |
joshema216 | 2:cb1f588caed7 | 247 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 248 | if (m!=0) { |
joshema216 | 2:cb1f588caed7 | 249 | tm.mon=tm.mon+m; |
joshema216 | 2:cb1f588caed7 | 250 | if(tm.mon>12){ |
joshema216 | 2:cb1f588caed7 | 251 | tm.mon=1; |
joshema216 | 2:cb1f588caed7 | 252 | } |
joshema216 | 2:cb1f588caed7 | 253 | if(tm.mon<1){ |
joshema216 | 2:cb1f588caed7 | 254 | tm.mon=1; |
joshema216 | 2:cb1f588caed7 | 255 | } |
joshema216 | 2:cb1f588caed7 | 256 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 257 | m=0; |
joshema216 | 2:cb1f588caed7 | 258 | } |
joshema216 | 2:cb1f588caed7 | 259 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 260 | lcd.printf("Mes: "); |
joshema216 | 2:cb1f588caed7 | 261 | lcd.locate(5,0); |
joshema216 | 2:cb1f588caed7 | 262 | lcd.printf("%02d",tm.mon); |
joshema216 | 2:cb1f588caed7 | 263 | if (button_enco.falling()){ |
joshema216 | 2:cb1f588caed7 | 264 | i++; |
joshema216 | 2:cb1f588caed7 | 265 | m=0; |
joshema216 | 2:cb1f588caed7 | 266 | } |
joshema216 | 2:cb1f588caed7 | 267 | } |
joshema216 | 2:cb1f588caed7 | 268 | |
joshema216 | 2:cb1f588caed7 | 269 | else if (i == 3){ // Modificar Año. |
joshema216 | 2:cb1f588caed7 | 270 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 271 | if (m!=0){ |
joshema216 | 2:cb1f588caed7 | 272 | tm.year=tm.year+m; |
joshema216 | 2:cb1f588caed7 | 273 | if(tm.year>2032){ |
joshema216 | 2:cb1f588caed7 | 274 | tm.year=2016; |
joshema216 | 2:cb1f588caed7 | 275 | } |
joshema216 | 2:cb1f588caed7 | 276 | if(tm.year<2000){ |
joshema216 | 2:cb1f588caed7 | 277 | tm.year=2000; |
joshema216 | 2:cb1f588caed7 | 278 | } |
joshema216 | 2:cb1f588caed7 | 279 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 280 | m=0; |
joshema216 | 2:cb1f588caed7 | 281 | } |
joshema216 | 2:cb1f588caed7 | 282 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 283 | lcd.printf("Year: "); |
joshema216 | 2:cb1f588caed7 | 284 | lcd.locate(6,0); |
joshema216 | 2:cb1f588caed7 | 285 | lcd.printf("%02d",tm.year); |
joshema216 | 2:cb1f588caed7 | 286 | if (button_enco.falling()){ |
joshema216 | 2:cb1f588caed7 | 287 | i++; |
joshema216 | 2:cb1f588caed7 | 288 | m = 0; |
joshema216 | 2:cb1f588caed7 | 289 | } |
joshema216 | 2:cb1f588caed7 | 290 | } |
Jepalacioh | 0:c2ed510ee88d | 291 | |
joshema216 | 2:cb1f588caed7 | 292 | else if (i == 4){ // Modificar Hora. |
joshema216 | 2:cb1f588caed7 | 293 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 294 | if (m!=0){ |
joshema216 | 2:cb1f588caed7 | 295 | tm.hour=tm.hour + m; |
joshema216 | 2:cb1f588caed7 | 296 | if(tm.hour>23){ |
joshema216 | 2:cb1f588caed7 | 297 | tm.hour=0; |
joshema216 | 2:cb1f588caed7 | 298 | } |
joshema216 | 2:cb1f588caed7 | 299 | if(tm.hour<0){ |
joshema216 | 2:cb1f588caed7 | 300 | tm.hour=0; |
joshema216 | 2:cb1f588caed7 | 301 | } |
joshema216 | 2:cb1f588caed7 | 302 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 303 | m=0; |
joshema216 | 2:cb1f588caed7 | 304 | } |
joshema216 | 2:cb1f588caed7 | 305 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 306 | lcd.printf("Hora: "); |
joshema216 | 2:cb1f588caed7 | 307 | lcd.locate(6,0); |
joshema216 | 2:cb1f588caed7 | 308 | lcd.printf("%02d",tm.hour); |
joshema216 | 2:cb1f588caed7 | 309 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 310 | lcd.printf(" "); |
joshema216 | 2:cb1f588caed7 | 311 | if (button_enco.falling()){ |
joshema216 | 2:cb1f588caed7 | 312 | i++; |
joshema216 | 2:cb1f588caed7 | 313 | m = 0; |
joshema216 | 2:cb1f588caed7 | 314 | } |
joshema216 | 2:cb1f588caed7 | 315 | } |
Jepalacioh | 0:c2ed510ee88d | 316 | |
joshema216 | 2:cb1f588caed7 | 317 | else if (i == 5){ // Modificar Minuto. |
joshema216 | 2:cb1f588caed7 | 318 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 319 | |
joshema216 | 2:cb1f588caed7 | 320 | if (m!=0){ |
joshema216 | 2:cb1f588caed7 | 321 | tm.min=tm.min+m; |
joshema216 | 2:cb1f588caed7 | 322 | if(tm.min>59){ |
joshema216 | 2:cb1f588caed7 | 323 | tm.min=0; |
joshema216 | 2:cb1f588caed7 | 324 | } |
joshema216 | 2:cb1f588caed7 | 325 | if(tm.min<0){ |
joshema216 | 2:cb1f588caed7 | 326 | tm.min=0; |
joshema216 | 2:cb1f588caed7 | 327 | } |
joshema216 | 2:cb1f588caed7 | 328 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 329 | m = 0; |
joshema216 | 2:cb1f588caed7 | 330 | } |
joshema216 | 2:cb1f588caed7 | 331 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 332 | lcd.printf("Minuto: "); |
joshema216 | 2:cb1f588caed7 | 333 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 334 | lcd.printf("%02d",tm.min); |
joshema216 | 2:cb1f588caed7 | 335 | if (button_enco.falling()){ |
joshema216 | 2:cb1f588caed7 | 336 | i++; |
joshema216 | 2:cb1f588caed7 | 337 | m = 0; |
joshema216 | 2:cb1f588caed7 | 338 | } |
joshema216 | 2:cb1f588caed7 | 339 | } |
Jepalacioh | 0:c2ed510ee88d | 340 | |
joshema216 | 2:cb1f588caed7 | 341 | else if (i == 6){ // Modificar Segundo. |
joshema216 | 2:cb1f588caed7 | 342 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 343 | if (m!=0){ |
joshema216 | 2:cb1f588caed7 | 344 | tm.sec=tm.sec+m; |
joshema216 | 2:cb1f588caed7 | 345 | if(tm.sec>59){ |
joshema216 | 2:cb1f588caed7 | 346 | tm.sec=0; |
joshema216 | 2:cb1f588caed7 | 347 | } |
joshema216 | 2:cb1f588caed7 | 348 | if(tm.sec<0){ |
joshema216 | 2:cb1f588caed7 | 349 | tm.sec=0; |
joshema216 | 2:cb1f588caed7 | 350 | } |
joshema216 | 2:cb1f588caed7 | 351 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 352 | m = 0; |
joshema216 | 2:cb1f588caed7 | 353 | } |
joshema216 | 2:cb1f588caed7 | 354 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 355 | lcd.printf("Segundo: "); |
joshema216 | 2:cb1f588caed7 | 356 | lcd.locate(9,0); |
joshema216 | 2:cb1f588caed7 | 357 | lcd.printf("%02d",tm.sec); |
joshema216 | 2:cb1f588caed7 | 358 | |
joshema216 | 2:cb1f588caed7 | 359 | if (button_enco.falling()){ // Empieza a asignar los datos del Reloj o las Alarmas. |
joshema216 | 2:cb1f588caed7 | 360 | if(Conf == 0){ // Asignar datos del Reloj. |
joshema216 | 2:cb1f588caed7 | 361 | rtc.setTime(tm, false, false); |
joshema216 | 2:cb1f588caed7 | 362 | pc.printf("Actualice el Reloj.\n"); |
joshema216 | 2:cb1f588caed7 | 363 | rtc.startClock(); |
joshema216 | 2:cb1f588caed7 | 364 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 365 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 366 | lcd.printf("Reloj"); |
joshema216 | 2:cb1f588caed7 | 367 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 368 | lcd.printf("configurado"); |
joshema216 | 2:cb1f588caed7 | 369 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 370 | i=0; |
joshema216 | 2:cb1f588caed7 | 371 | m=0; |
joshema216 | 2:cb1f588caed7 | 372 | Lugar = 0; |
joshema216 | 2:cb1f588caed7 | 373 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 374 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 375 | lcd.printf("--Reloj"); |
joshema216 | 2:cb1f588caed7 | 376 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 377 | lcd.printf("--Alarmas"); |
joshema216 | 2:cb1f588caed7 | 378 | ala = 0; |
joshema216 | 2:cb1f588caed7 | 379 | } |
Jepalacioh | 0:c2ed510ee88d | 380 | |
joshema216 | 2:cb1f588caed7 | 381 | if(Conf == 1 && ala == 2){ // Asignar datos de la Alarma 1 encendido. |
joshema216 | 2:cb1f588caed7 | 382 | A1on = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 383 | pc.printf("Actualice Alarma 1 on.\n"); |
joshema216 | 2:cb1f588caed7 | 384 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 385 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 386 | lcd.printf("Alarma 1 (on)"); |
joshema216 | 2:cb1f588caed7 | 387 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 388 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 389 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 390 | i=0; |
joshema216 | 2:cb1f588caed7 | 391 | m=0; |
joshema216 | 2:cb1f588caed7 | 392 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 393 | } |
Jepalacioh | 0:c2ed510ee88d | 394 | |
joshema216 | 2:cb1f588caed7 | 395 | if(Conf == 1 && ala == 3){ // Asignar datos de la Alarma 1 apagado. |
joshema216 | 2:cb1f588caed7 | 396 | A1off = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 397 | pc.printf("Actualice Alarma 1 off.\n"); |
joshema216 | 2:cb1f588caed7 | 398 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 399 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 400 | lcd.printf("Alarma 1 (off)"); |
joshema216 | 2:cb1f588caed7 | 401 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 402 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 403 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 404 | i=0; |
joshema216 | 2:cb1f588caed7 | 405 | m=0; |
joshema216 | 2:cb1f588caed7 | 406 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 407 | } |
Jepalacioh | 0:c2ed510ee88d | 408 | |
joshema216 | 2:cb1f588caed7 | 409 | if(Conf == 1 && ala == 4){ // Asignar datos de la Alarma 2 encendido. |
joshema216 | 2:cb1f588caed7 | 410 | A2on = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 411 | pc.printf("Actualice Alarma 2 on.\n"); |
joshema216 | 2:cb1f588caed7 | 412 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 413 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 414 | lcd.printf("Alarma 2 (on)"); |
joshema216 | 2:cb1f588caed7 | 415 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 416 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 417 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 418 | i=0; |
joshema216 | 2:cb1f588caed7 | 419 | m=0; |
joshema216 | 2:cb1f588caed7 | 420 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 421 | } |
Jepalacioh | 0:c2ed510ee88d | 422 | |
joshema216 | 2:cb1f588caed7 | 423 | if(Conf == 1 && ala == 5){ // Asignar datos de la Alarma 2 apagado. |
joshema216 | 2:cb1f588caed7 | 424 | A2off = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 425 | pc.printf("Actualice Alarma 2 off.\n"); |
joshema216 | 2:cb1f588caed7 | 426 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 427 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 428 | lcd.printf("Alarma 2 (off)"); |
joshema216 | 2:cb1f588caed7 | 429 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 430 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 431 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 432 | i=0; |
joshema216 | 2:cb1f588caed7 | 433 | m=0; |
joshema216 | 2:cb1f588caed7 | 434 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 435 | } |
Jepalacioh | 0:c2ed510ee88d | 436 | |
joshema216 | 2:cb1f588caed7 | 437 | if(Conf == 1 && ala == 6){ // Asignar datos de la Alarma 3 encendido. |
joshema216 | 2:cb1f588caed7 | 438 | A3on = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 439 | pc.printf("Actualice Alarma 3 on.\n"); |
joshema216 | 2:cb1f588caed7 | 440 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 441 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 442 | lcd.printf("Alarma 3 (on)"); |
joshema216 | 2:cb1f588caed7 | 443 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 444 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 445 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 446 | i=0; |
joshema216 | 2:cb1f588caed7 | 447 | m=0; |
joshema216 | 2:cb1f588caed7 | 448 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 449 | } |
Jepalacioh | 0:c2ed510ee88d | 450 | |
joshema216 | 2:cb1f588caed7 | 451 | if(Conf == 1 && ala == 7){ // Asignar datos de la Alarma 3 apagado. |
joshema216 | 2:cb1f588caed7 | 452 | A3off = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 453 | pc.printf("Actualice Alarma 3 off.\n"); |
joshema216 | 2:cb1f588caed7 | 454 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 455 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 456 | lcd.printf("Alarma 3 (off)"); |
joshema216 | 2:cb1f588caed7 | 457 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 458 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 459 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 460 | i=0; |
Jepalacioh | 0:c2ed510ee88d | 461 | m=0; |
joshema216 | 2:cb1f588caed7 | 462 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 463 | } |
joshema216 | 2:cb1f588caed7 | 464 | |
joshema216 | 2:cb1f588caed7 | 465 | if(Conf == 1 && ala == 8){ // Asignar datos de la Alarma 4 encendido. |
joshema216 | 2:cb1f588caed7 | 466 | A4on = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 467 | pc.printf("Actualice Alarma 4 on.\n"); |
joshema216 | 2:cb1f588caed7 | 468 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 469 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 470 | lcd.printf("Alarma 4 (on)"); |
joshema216 | 2:cb1f588caed7 | 471 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 472 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 473 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 474 | i=0; |
joshema216 | 2:cb1f588caed7 | 475 | m=0; |
joshema216 | 2:cb1f588caed7 | 476 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 477 | } |
Jepalacioh | 0:c2ed510ee88d | 478 | |
joshema216 | 2:cb1f588caed7 | 479 | if(Conf == 1 && ala == 9){ // Asignar datos de la Alarma 4 apagado. |
joshema216 | 2:cb1f588caed7 | 480 | A4off = tm; // A la alarma le pone todo eso. |
joshema216 | 2:cb1f588caed7 | 481 | pc.printf("Actualice Alarma 4 off.\n"); |
Jepalacioh | 0:c2ed510ee88d | 482 | lcd.cls(); |
Jepalacioh | 0:c2ed510ee88d | 483 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 484 | lcd.printf("Alarma 4 (off)"); |
joshema216 | 2:cb1f588caed7 | 485 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 486 | lcd.printf("configurada"); |
joshema216 | 2:cb1f588caed7 | 487 | wait(1.5); |
joshema216 | 2:cb1f588caed7 | 488 | i=0; |
joshema216 | 2:cb1f588caed7 | 489 | m=0; |
joshema216 | 2:cb1f588caed7 | 490 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 491 | Lugar++; |
Jepalacioh | 0:c2ed510ee88d | 492 | } |
joshema216 | 2:cb1f588caed7 | 493 | ala++; |
joshema216 | 2:cb1f588caed7 | 494 | } // Cierre de if de mensaje de configuración. |
joshema216 | 2:cb1f588caed7 | 495 | } // Cierre de if de i == 6 |
joshema216 | 2:cb1f588caed7 | 496 | } // Cierre de if de Lugar == 1 |
joshema216 | 2:cb1f588caed7 | 497 | |
joshema216 | 2:cb1f588caed7 | 498 | // Etapa de comparación e impresión. |
joshema216 | 2:cb1f588caed7 | 499 | else if (Lugar == 2){ // La visualización del los tiempos de las alarmas y el reloj varían si se manipula en encoder. |
joshema216 | 2:cb1f588caed7 | 500 | rtc.getTime(tm); |
joshema216 | 2:cb1f588caed7 | 501 | if(visual == 0){ // Imprime el Reloj. |
joshema216 | 2:cb1f588caed7 | 502 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 503 | lcd.printf("Hora: "); |
joshema216 | 2:cb1f588caed7 | 504 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 505 | lcd.printf("%02d:",tm.hour); |
joshema216 | 2:cb1f588caed7 | 506 | lcd.printf("%02d:",tm.min); |
joshema216 | 2:cb1f588caed7 | 507 | lcd.printf("%02d",tm.sec); |
joshema216 | 2:cb1f588caed7 | 508 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 509 | lcd.printf("%02d/",tm.mon); |
joshema216 | 2:cb1f588caed7 | 510 | lcd.printf("%02d/",tm.date); |
joshema216 | 2:cb1f588caed7 | 511 | lcd.printf("%02d",tm.year); |
joshema216 | 2:cb1f588caed7 | 512 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 513 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 514 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 515 | visual++; |
joshema216 | 2:cb1f588caed7 | 516 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 517 | m = 0; |
joshema216 | 2:cb1f588caed7 | 518 | } |
joshema216 | 2:cb1f588caed7 | 519 | } |
joshema216 | 2:cb1f588caed7 | 520 | |
joshema216 | 2:cb1f588caed7 | 521 | if(visual == 1){ // Imprime la alarma 1 encendido. |
joshema216 | 2:cb1f588caed7 | 522 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 523 | lcd.printf("A1 on: "); |
joshema216 | 2:cb1f588caed7 | 524 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 525 | lcd.printf("%02d:",A1on.hour); |
joshema216 | 2:cb1f588caed7 | 526 | lcd.printf("%02d:",A1on.min); |
joshema216 | 2:cb1f588caed7 | 527 | lcd.printf("%02d",A1on.sec); |
joshema216 | 2:cb1f588caed7 | 528 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 529 | lcd.printf("%02d/",A1on.mon); |
joshema216 | 2:cb1f588caed7 | 530 | lcd.printf("%02d/",A1on.date); |
joshema216 | 2:cb1f588caed7 | 531 | lcd.printf("%02d",A1on.year); |
joshema216 | 2:cb1f588caed7 | 532 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 533 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 534 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 535 | visual++; |
joshema216 | 2:cb1f588caed7 | 536 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 537 | m=0; |
joshema216 | 2:cb1f588caed7 | 538 | } |
joshema216 | 2:cb1f588caed7 | 539 | } |
joshema216 | 2:cb1f588caed7 | 540 | |
joshema216 | 2:cb1f588caed7 | 541 | if(visual == 2){ // Imprime la alarma 1 apagado. |
joshema216 | 2:cb1f588caed7 | 542 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 543 | lcd.printf("A1 off: "); |
joshema216 | 2:cb1f588caed7 | 544 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 545 | lcd.printf("%02d:",A1off.hour); |
joshema216 | 2:cb1f588caed7 | 546 | lcd.printf("%02d:",A1off.min); |
joshema216 | 2:cb1f588caed7 | 547 | lcd.printf("%02d",A1off.sec); |
joshema216 | 2:cb1f588caed7 | 548 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 549 | lcd.printf("%02d/",A1off.mon); |
joshema216 | 2:cb1f588caed7 | 550 | lcd.printf("%02d/",A1off.date); |
joshema216 | 2:cb1f588caed7 | 551 | lcd.printf("%02d",A1off.year); |
joshema216 | 2:cb1f588caed7 | 552 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 553 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 554 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 555 | visual++; |
joshema216 | 2:cb1f588caed7 | 556 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 557 | m=0; |
joshema216 | 2:cb1f588caed7 | 558 | } |
joshema216 | 2:cb1f588caed7 | 559 | } |
joshema216 | 2:cb1f588caed7 | 560 | |
joshema216 | 2:cb1f588caed7 | 561 | if(visual == 3){ // Imprime la alarma 2 encendido. |
joshema216 | 2:cb1f588caed7 | 562 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 563 | lcd.printf("A2 on: "); |
joshema216 | 2:cb1f588caed7 | 564 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 565 | lcd.printf("%02d:",A2on.hour); |
joshema216 | 2:cb1f588caed7 | 566 | lcd.printf("%02d:",A2on.min); |
joshema216 | 2:cb1f588caed7 | 567 | lcd.printf("%02d",A2on.sec); |
joshema216 | 2:cb1f588caed7 | 568 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 569 | lcd.printf("%02d/",A2on.mon); |
joshema216 | 2:cb1f588caed7 | 570 | lcd.printf("%02d/",A2on.date); |
joshema216 | 2:cb1f588caed7 | 571 | lcd.printf("%02d",A2on.year); |
joshema216 | 2:cb1f588caed7 | 572 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 573 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 574 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 575 | visual++; |
joshema216 | 2:cb1f588caed7 | 576 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 577 | m=0; |
joshema216 | 2:cb1f588caed7 | 578 | } |
joshema216 | 2:cb1f588caed7 | 579 | } |
joshema216 | 2:cb1f588caed7 | 580 | |
joshema216 | 2:cb1f588caed7 | 581 | if(visual == 4){ // Imprime la alarma 2 apagado. |
joshema216 | 2:cb1f588caed7 | 582 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 583 | lcd.printf("A2 off: "); |
joshema216 | 2:cb1f588caed7 | 584 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 585 | lcd.printf("%02d:",A2off.hour); |
joshema216 | 2:cb1f588caed7 | 586 | lcd.printf("%02d:",A2off.min); |
joshema216 | 2:cb1f588caed7 | 587 | lcd.printf("%02d",A2off.sec); |
joshema216 | 2:cb1f588caed7 | 588 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 589 | lcd.printf("%02d/",A2off.mon); |
joshema216 | 2:cb1f588caed7 | 590 | lcd.printf("%02d/",A2off.date); |
joshema216 | 2:cb1f588caed7 | 591 | lcd.printf("%02d",A2off.year); |
joshema216 | 2:cb1f588caed7 | 592 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 593 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 594 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 595 | visual++; |
joshema216 | 2:cb1f588caed7 | 596 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 597 | m=0; |
joshema216 | 2:cb1f588caed7 | 598 | } |
joshema216 | 2:cb1f588caed7 | 599 | } |
joshema216 | 2:cb1f588caed7 | 600 | |
joshema216 | 2:cb1f588caed7 | 601 | if(visual == 5){ // Imprime la alarma 3 encendido. |
joshema216 | 2:cb1f588caed7 | 602 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 603 | lcd.printf("A3 on: "); |
joshema216 | 2:cb1f588caed7 | 604 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 605 | lcd.printf("%02d:",A3on.hour); |
joshema216 | 2:cb1f588caed7 | 606 | lcd.printf("%02d:",A3on.min); |
joshema216 | 2:cb1f588caed7 | 607 | lcd.printf("%02d",A3on.sec); |
joshema216 | 2:cb1f588caed7 | 608 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 609 | lcd.printf("%02d/",A3on.mon); |
joshema216 | 2:cb1f588caed7 | 610 | lcd.printf("%02d/",A3on.date); |
joshema216 | 2:cb1f588caed7 | 611 | lcd.printf("%02d",A3on.year); |
joshema216 | 2:cb1f588caed7 | 612 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 613 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 614 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 615 | visual++; |
joshema216 | 2:cb1f588caed7 | 616 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 617 | m=0; |
joshema216 | 2:cb1f588caed7 | 618 | } |
joshema216 | 2:cb1f588caed7 | 619 | } |
joshema216 | 2:cb1f588caed7 | 620 | |
joshema216 | 2:cb1f588caed7 | 621 | if(visual == 6){ // Imprime la alarma 3 apagado. |
joshema216 | 2:cb1f588caed7 | 622 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 623 | lcd.printf("A3 off: "); |
joshema216 | 2:cb1f588caed7 | 624 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 625 | lcd.printf("%02d:",A3off.hour); |
joshema216 | 2:cb1f588caed7 | 626 | lcd.printf("%02d:",A3off.min); |
joshema216 | 2:cb1f588caed7 | 627 | lcd.printf("%02d",A3off.sec); |
joshema216 | 2:cb1f588caed7 | 628 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 629 | lcd.printf("%02d/",A3off.mon); |
joshema216 | 2:cb1f588caed7 | 630 | lcd.printf("%02d/",A3off.date); |
joshema216 | 2:cb1f588caed7 | 631 | lcd.printf("%02d",A3off.year); |
joshema216 | 2:cb1f588caed7 | 632 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 633 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 634 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 635 | visual++; |
joshema216 | 2:cb1f588caed7 | 636 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 637 | m=0; |
Jepalacioh | 0:c2ed510ee88d | 638 | } |
joshema216 | 2:cb1f588caed7 | 639 | } |
joshema216 | 2:cb1f588caed7 | 640 | |
joshema216 | 2:cb1f588caed7 | 641 | if(visual == 7){ // Imprime la alarma 4 encendido. |
joshema216 | 2:cb1f588caed7 | 642 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 643 | lcd.printf("A4 on: "); |
joshema216 | 2:cb1f588caed7 | 644 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 645 | lcd.printf("%02d:",A4on.hour); |
joshema216 | 2:cb1f588caed7 | 646 | lcd.printf("%02d:",A4on.min); |
joshema216 | 2:cb1f588caed7 | 647 | lcd.printf("%02d",A4on.sec); |
joshema216 | 2:cb1f588caed7 | 648 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 649 | lcd.printf("%02d/",A4on.mon); |
joshema216 | 2:cb1f588caed7 | 650 | lcd.printf("%02d/",A4on.date); |
joshema216 | 2:cb1f588caed7 | 651 | lcd.printf("%02d",A4on.year); |
joshema216 | 2:cb1f588caed7 | 652 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 653 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 654 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 655 | visual++; |
joshema216 | 2:cb1f588caed7 | 656 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 657 | m=0; |
joshema216 | 2:cb1f588caed7 | 658 | } |
joshema216 | 2:cb1f588caed7 | 659 | } |
joshema216 | 2:cb1f588caed7 | 660 | |
joshema216 | 2:cb1f588caed7 | 661 | if(visual == 8){ // Imprime la alarma 4 apagado. |
joshema216 | 2:cb1f588caed7 | 662 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 663 | lcd.printf("A4 off: "); |
joshema216 | 2:cb1f588caed7 | 664 | lcd.locate(8,0); |
joshema216 | 2:cb1f588caed7 | 665 | lcd.printf("%02d:",A4off.hour); |
joshema216 | 2:cb1f588caed7 | 666 | lcd.printf("%02d:",A4off.min); |
joshema216 | 2:cb1f588caed7 | 667 | lcd.printf("%02d",A4off.sec); |
joshema216 | 2:cb1f588caed7 | 668 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 669 | lcd.printf("%02d/",A4off.mon); |
joshema216 | 2:cb1f588caed7 | 670 | lcd.printf("%02d/",A4off.date); |
joshema216 | 2:cb1f588caed7 | 671 | lcd.printf("%02d",A4off.year); |
joshema216 | 2:cb1f588caed7 | 672 | wait(0.1); |
joshema216 | 2:cb1f588caed7 | 673 | m = wheel.getPulses(); |
joshema216 | 2:cb1f588caed7 | 674 | if(m!=0){ |
joshema216 | 2:cb1f588caed7 | 675 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 676 | wheel.reset(); |
joshema216 | 2:cb1f588caed7 | 677 | m=0; |
joshema216 | 2:cb1f588caed7 | 678 | } |
joshema216 | 2:cb1f588caed7 | 679 | } |
joshema216 | 2:cb1f588caed7 | 680 | |
joshema216 | 2:cb1f588caed7 | 681 | // Compara el Reloj con la alarma 1 encendido. |
joshema216 | 2:cb1f588caed7 | 682 | if( (tm.date==A1on.date)&&(tm.mon==A1on.mon)&&(tm.year==A1on.year)&&(tm.hour==A1on.hour)&&(tm.min==A1on.min)&&(tm.sec==A1on.sec) ){ |
joshema216 | 2:cb1f588caed7 | 683 | ALED1 = 1; // Prende el LED 1. |
joshema216 | 2:cb1f588caed7 | 684 | a1 = 1; |
joshema216 | 2:cb1f588caed7 | 685 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 686 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 687 | lcd.printf("Alarma 1"); |
joshema216 | 2:cb1f588caed7 | 688 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 689 | lcd.printf("activada!"); |
joshema216 | 2:cb1f588caed7 | 690 | wait(2); |
joshema216 | 2:cb1f588caed7 | 691 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 692 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 693 | m = 0; |
joshema216 | 2:cb1f588caed7 | 694 | } |
joshema216 | 2:cb1f588caed7 | 695 | |
joshema216 | 2:cb1f588caed7 | 696 | // Compara el Reloj con la alarma 1 apagado. |
joshema216 | 2:cb1f588caed7 | 697 | if( (tm.date == A1off.date)&&(tm.mon == A1off.mon)&&(tm.year == A1off.year)&&(tm.hour == A1off.hour)&&(tm.min == A1off.min)&&(tm.sec == A1off.sec)&&(a1 == 1)){ |
joshema216 | 2:cb1f588caed7 | 698 | ALED1 = 0; // Apaga el LED 1. |
joshema216 | 2:cb1f588caed7 | 699 | a1 = 0; |
joshema216 | 2:cb1f588caed7 | 700 | //Lugar++; |
joshema216 | 2:cb1f588caed7 | 701 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 702 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 703 | lcd.printf("Alarma 1"); |
joshema216 | 2:cb1f588caed7 | 704 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 705 | lcd.printf("desactivada"); |
joshema216 | 2:cb1f588caed7 | 706 | wait(2); |
joshema216 | 2:cb1f588caed7 | 707 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 708 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 709 | m = 0; |
joshema216 | 2:cb1f588caed7 | 710 | cont++; |
joshema216 | 2:cb1f588caed7 | 711 | } |
joshema216 | 2:cb1f588caed7 | 712 | |
joshema216 | 2:cb1f588caed7 | 713 | // Compara el Reloj con la alarma 2 encendido. |
joshema216 | 2:cb1f588caed7 | 714 | if( (tm.date == A2on.date)&&(tm.mon == A2on.mon)&&(tm.year == A2on.year)&&(tm.hour == A2on.hour)&&(tm.min == A2on.min)&&(tm.sec == A2on.sec)){ |
joshema216 | 2:cb1f588caed7 | 715 | ALED2= 2; // Prende el LED 2. |
joshema216 | 2:cb1f588caed7 | 716 | a2 = 1; |
joshema216 | 2:cb1f588caed7 | 717 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 718 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 719 | lcd.printf("Alarma 2"); |
joshema216 | 2:cb1f588caed7 | 720 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 721 | lcd.printf("activada!"); |
joshema216 | 2:cb1f588caed7 | 722 | wait(2); |
joshema216 | 2:cb1f588caed7 | 723 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 724 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 725 | m = 0; |
joshema216 | 2:cb1f588caed7 | 726 | } |
Jepalacioh | 0:c2ed510ee88d | 727 | |
joshema216 | 2:cb1f588caed7 | 728 | // Compara el Reloj con la alarma 2 apagado. |
joshema216 | 2:cb1f588caed7 | 729 | if( (tm.date == A2off.date)&&(tm.mon == A2off.mon)&&(tm.year == A2off.year)&&(tm.hour == A2off.hour)&&(tm.min == A2off.min)&&(tm.sec == A2off.sec)&&(a2 == 1)){ |
joshema216 | 2:cb1f588caed7 | 730 | ALED2 = 0; // Apaga el LED 2. |
joshema216 | 2:cb1f588caed7 | 731 | a2 = 0; |
joshema216 | 2:cb1f588caed7 | 732 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 733 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 734 | lcd.printf("Alarma 2"); |
joshema216 | 2:cb1f588caed7 | 735 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 736 | lcd.printf("desactivada"); |
joshema216 | 2:cb1f588caed7 | 737 | wait(2); |
joshema216 | 2:cb1f588caed7 | 738 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 739 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 740 | m = 0; |
joshema216 | 2:cb1f588caed7 | 741 | cont++; |
joshema216 | 2:cb1f588caed7 | 742 | } |
joshema216 | 2:cb1f588caed7 | 743 | |
joshema216 | 2:cb1f588caed7 | 744 | // Compara el Reloj con la alarma 3 encendido. |
joshema216 | 2:cb1f588caed7 | 745 | if( (tm.date == A3on.date)&&(tm.mon == A3on.mon)&&(tm.year == A3on.year)&&(tm.hour == A3on.hour)&&(tm.min == A3on.min)&&(tm.sec == A3on.sec)){ |
joshema216 | 2:cb1f588caed7 | 746 | ALED3 = 1; // Prende el LED 3. |
joshema216 | 2:cb1f588caed7 | 747 | a3 = 1; |
joshema216 | 2:cb1f588caed7 | 748 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 749 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 750 | lcd.printf("Alarma 3"); |
joshema216 | 2:cb1f588caed7 | 751 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 752 | lcd.printf("activada!"); |
joshema216 | 2:cb1f588caed7 | 753 | wait(2); |
joshema216 | 2:cb1f588caed7 | 754 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 755 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 756 | m = 0; |
joshema216 | 2:cb1f588caed7 | 757 | } |
joshema216 | 2:cb1f588caed7 | 758 | |
joshema216 | 2:cb1f588caed7 | 759 | // Compara el Reloj con la alarma 3 apagado. |
joshema216 | 2:cb1f588caed7 | 760 | if( (tm.date == A3off.date)&&(tm.mon == A3off.mon)&&(tm.year == A3off.year)&&(tm.hour == A3off.hour)&&(tm.min == A3off.min)&&(tm.sec == A3off.sec)&&(a3 == 1)){ |
joshema216 | 2:cb1f588caed7 | 761 | ALED3 = 0; // Apaga el LED 3. |
joshema216 | 2:cb1f588caed7 | 762 | a3 = 0; |
joshema216 | 2:cb1f588caed7 | 763 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 764 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 765 | lcd.printf("Alarma 3"); |
joshema216 | 2:cb1f588caed7 | 766 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 767 | lcd.printf("desactivada"); |
joshema216 | 2:cb1f588caed7 | 768 | wait(2); |
joshema216 | 2:cb1f588caed7 | 769 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 770 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 771 | m = 0; |
joshema216 | 2:cb1f588caed7 | 772 | cont++; |
joshema216 | 2:cb1f588caed7 | 773 | } |
joshema216 | 2:cb1f588caed7 | 774 | |
joshema216 | 2:cb1f588caed7 | 775 | // Compara el Reloj con la alarma 4 encendido. |
joshema216 | 2:cb1f588caed7 | 776 | if( (tm.date == A4on.date)&&(tm.mon == A4on.mon)&&(tm.year == A4on.year)&&(tm.hour == A4on.hour)&&(tm.min == A4on.min)&&(tm.sec == A4on.sec)){ |
joshema216 | 2:cb1f588caed7 | 777 | ALED4 = 1; // Prende el LED 4. |
joshema216 | 2:cb1f588caed7 | 778 | a4 = 1; |
joshema216 | 2:cb1f588caed7 | 779 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 780 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 781 | lcd.printf("Alarma 4"); |
joshema216 | 2:cb1f588caed7 | 782 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 783 | lcd.printf("activada!"); |
joshema216 | 2:cb1f588caed7 | 784 | wait(2); |
joshema216 | 2:cb1f588caed7 | 785 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 786 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 787 | m = 0; |
joshema216 | 2:cb1f588caed7 | 788 | } |
joshema216 | 2:cb1f588caed7 | 789 | |
joshema216 | 2:cb1f588caed7 | 790 | // Compara el Reloj con la alarma 4 apagado. |
joshema216 | 2:cb1f588caed7 | 791 | if( (tm.date == A4off.date)&&(tm.mon == A4off.mon)&&(tm.year == A4off.year)&&(tm.hour == A4off.hour)&&(tm.min == A4off.min)&&(tm.sec == A4off.sec)&&(a4 == 1)){ |
joshema216 | 2:cb1f588caed7 | 792 | ALED4 = 0; // Apaga el LED 4. |
joshema216 | 2:cb1f588caed7 | 793 | a4 = 0; |
joshema216 | 2:cb1f588caed7 | 794 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 795 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 796 | lcd.printf("Alarma 4"); |
joshema216 | 2:cb1f588caed7 | 797 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 798 | lcd.printf("desactivada"); |
joshema216 | 2:cb1f588caed7 | 799 | wait(2); |
joshema216 | 2:cb1f588caed7 | 800 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 801 | visual = 0; |
joshema216 | 2:cb1f588caed7 | 802 | m = 0; |
joshema216 | 2:cb1f588caed7 | 803 | cont++; |
joshema216 | 2:cb1f588caed7 | 804 | } |
joshema216 | 2:cb1f588caed7 | 805 | |
joshema216 | 2:cb1f588caed7 | 806 | if(cont == 4){ // Cuando se cumplen todas las Alarmas se regresa al menú principal. |
joshema216 | 2:cb1f588caed7 | 807 | Lugar = 0; |
joshema216 | 2:cb1f588caed7 | 808 | lcd.cls(); |
joshema216 | 2:cb1f588caed7 | 809 | lcd.locate(0,0); |
joshema216 | 2:cb1f588caed7 | 810 | lcd.printf("--Reloj"); // Sin flechitas. |
joshema216 | 2:cb1f588caed7 | 811 | lcd.locate(0,1); |
joshema216 | 2:cb1f588caed7 | 812 | lcd.printf("--Alarmas"); |
joshema216 | 2:cb1f588caed7 | 813 | m = 0; |
joshema216 | 2:cb1f588caed7 | 814 | } |
joshema216 | 2:cb1f588caed7 | 815 | } |
joshema216 | 2:cb1f588caed7 | 816 | } |
joshema216 | 2:cb1f588caed7 | 817 | } |