![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Configuracion de Alarma y Hora, mediante LCD y Teclado, Navego por el menu con las teclas A, B, D, *, #.
Dependencies: Debounced FPointer RTC-DS1307 TextLCD keypad mbed
main.cpp@0:8471537b0784, 2014-05-08 (annotated)
- Committer:
- Jesse
- Date:
- Thu May 08 22:38:48 2014 +0000
- Revision:
- 0:8471537b0784
Tarea 5_Alarma DS1307
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jesse | 0:8471537b0784 | 1 | //el Puerto Serial |
Jesse | 0:8471537b0784 | 2 | //Jesse Mauricio Beltran |
Jesse | 0:8471537b0784 | 3 | //Michelle Maceas Henao |
Jesse | 0:8471537b0784 | 4 | |
Jesse | 0:8471537b0784 | 5 | #include "mbed.h" |
Jesse | 0:8471537b0784 | 6 | #include "Rtc_Ds1307.h" |
Jesse | 0:8471537b0784 | 7 | #include "TextLCD.h" |
Jesse | 0:8471537b0784 | 8 | #include "DebouncedIn.h" |
Jesse | 0:8471537b0784 | 9 | #include "keypad.h" |
Jesse | 0:8471537b0784 | 10 | |
Jesse | 0:8471537b0784 | 11 | PwmOut Pwm(PTA5); |
Jesse | 0:8471537b0784 | 12 | DebouncedIn Aumen(PTC10); |
Jesse | 0:8471537b0784 | 13 | DebouncedIn Panta(PTC11); |
Jesse | 0:8471537b0784 | 14 | DebouncedIn Decre(PTC6); |
Jesse | 0:8471537b0784 | 15 | DebouncedIn Ensayo(PTC7); |
Jesse | 0:8471537b0784 | 16 | |
Jesse | 0:8471537b0784 | 17 | |
Jesse | 0:8471537b0784 | 18 | TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7#include "TextLCD.h" |
Jesse | 0:8471537b0784 | 19 | Rtc_Ds1307 rtc(PTE0,PTE1); |
Jesse | 0:8471537b0784 | 20 | Serial pc(USBTX, USBRX); |
Jesse | 0:8471537b0784 | 21 | |
Jesse | 0:8471537b0784 | 22 | int Start=0,Read=0,Write=0,Menu=0,Menu2=0,Hora=0,Minuto=0,Segundo=0,pp=0,Dia=0,Dya=0,Mes=0,Anno=2014,Encendido=0,Aumen2=0,Decre2=0,flag2=0; |
Jesse | 0:8471537b0784 | 23 | float ppp=0.001; |
Jesse | 0:8471537b0784 | 24 | float Dd=0.1; |
Jesse | 0:8471537b0784 | 25 | int p=0,c=0,d=0,e=0,flag=0,ff=0,hh=0; |
Jesse | 0:8471537b0784 | 26 | int key; |
Jesse | 0:8471537b0784 | 27 | |
Jesse | 0:8471537b0784 | 28 | |
Jesse | 0:8471537b0784 | 29 | int PWMmodule(float ppp,float Dd) |
Jesse | 0:8471537b0784 | 30 | { |
Jesse | 0:8471537b0784 | 31 | Pwm.period(ppp); |
Jesse | 0:8471537b0784 | 32 | Pwm.write(Dd); |
Jesse | 0:8471537b0784 | 33 | wait(0.2); |
Jesse | 0:8471537b0784 | 34 | Pwm.write(0); |
Jesse | 0:8471537b0784 | 35 | return 0; |
Jesse | 0:8471537b0784 | 36 | } |
Jesse | 0:8471537b0784 | 37 | |
Jesse | 0:8471537b0784 | 38 | |
Jesse | 0:8471537b0784 | 39 | char Keytable[] = { '1', '2', '3', 'A', |
Jesse | 0:8471537b0784 | 40 | '4', '5', '6', 'B', |
Jesse | 0:8471537b0784 | 41 | '7', '8', '9', 'C', |
Jesse | 0:8471537b0784 | 42 | '*', '0', '#', 'D' |
Jesse | 0:8471537b0784 | 43 | }; |
Jesse | 0:8471537b0784 | 44 | |
Jesse | 0:8471537b0784 | 45 | uint32_t cbAfterInput(uint32_t Key) |
Jesse | 0:8471537b0784 | 46 | { |
Jesse | 0:8471537b0784 | 47 | |
Jesse | 0:8471537b0784 | 48 | key=Key; |
Jesse | 0:8471537b0784 | 49 | if(Keytable[key]=='B') |
Jesse | 0:8471537b0784 | 50 | { |
Jesse | 0:8471537b0784 | 51 | PWMmodule(ppp,Dd); |
Jesse | 0:8471537b0784 | 52 | Write=0; |
Jesse | 0:8471537b0784 | 53 | Read=1; |
Jesse | 0:8471537b0784 | 54 | lcd.cls(); |
Jesse | 0:8471537b0784 | 55 | lcd.printf("Configuacion de"); |
Jesse | 0:8471537b0784 | 56 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 57 | lcd.printf(" Alarma"); |
Jesse | 0:8471537b0784 | 58 | wait(2); |
Jesse | 0:8471537b0784 | 59 | lcd.cls(); |
Jesse | 0:8471537b0784 | 60 | lcd.printf("Presione D"); |
Jesse | 0:8471537b0784 | 61 | } |
Jesse | 0:8471537b0784 | 62 | if(Keytable[key]=='A') |
Jesse | 0:8471537b0784 | 63 | { |
Jesse | 0:8471537b0784 | 64 | PWMmodule(ppp,Dd); |
Jesse | 0:8471537b0784 | 65 | Write=1; |
Jesse | 0:8471537b0784 | 66 | Read=0; |
Jesse | 0:8471537b0784 | 67 | lcd.cls(); |
Jesse | 0:8471537b0784 | 68 | lcd.printf("Configuacion del"); |
Jesse | 0:8471537b0784 | 69 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 70 | lcd.printf(" Reloj"); |
Jesse | 0:8471537b0784 | 71 | wait(2); |
Jesse | 0:8471537b0784 | 72 | lcd.cls(); |
Jesse | 0:8471537b0784 | 73 | lcd.printf("Presione D"); |
Jesse | 0:8471537b0784 | 74 | } |
Jesse | 0:8471537b0784 | 75 | |
Jesse | 0:8471537b0784 | 76 | if(Keytable[key]=='D') |
Jesse | 0:8471537b0784 | 77 | { |
Jesse | 0:8471537b0784 | 78 | Menu=Menu+1; |
Jesse | 0:8471537b0784 | 79 | } |
Jesse | 0:8471537b0784 | 80 | if(Keytable[key]=='*') |
Jesse | 0:8471537b0784 | 81 | { |
Jesse | 0:8471537b0784 | 82 | Aumen2=1; |
Jesse | 0:8471537b0784 | 83 | } |
Jesse | 0:8471537b0784 | 84 | if(Keytable[key]=='#') |
Jesse | 0:8471537b0784 | 85 | { |
Jesse | 0:8471537b0784 | 86 | Decre2=1; |
Jesse | 0:8471537b0784 | 87 | } |
Jesse | 0:8471537b0784 | 88 | |
Jesse | 0:8471537b0784 | 89 | return 0; |
Jesse | 0:8471537b0784 | 90 | } |
Jesse | 0:8471537b0784 | 91 | |
Jesse | 0:8471537b0784 | 92 | int main() |
Jesse | 0:8471537b0784 | 93 | { |
Jesse | 0:8471537b0784 | 94 | Keypad keypad(PTA2,PTD4,PTD3,PTD1,PTD2,PTD0,PTD5,PTA13); |
Jesse | 0:8471537b0784 | 95 | keypad.CallAfterInput(&cbAfterInput); |
Jesse | 0:8471537b0784 | 96 | keypad.Start(); // energiza las columnas C0-C3 Del Keypad |
Jesse | 0:8471537b0784 | 97 | Rtc_Ds1307::Time_rtc tm = {}; |
Jesse | 0:8471537b0784 | 98 | |
Jesse | 0:8471537b0784 | 99 | lcd.printf(" Bienvenido "); |
Jesse | 0:8471537b0784 | 100 | wait(1); |
Jesse | 0:8471537b0784 | 101 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 102 | lcd.printf(" Presione:"); |
Jesse | 0:8471537b0784 | 103 | wait(2); |
Jesse | 0:8471537b0784 | 104 | lcd.cls(); |
Jesse | 0:8471537b0784 | 105 | lcd.locate(0,0); |
Jesse | 0:8471537b0784 | 106 | lcd.printf("A.Config Reloj"); |
Jesse | 0:8471537b0784 | 107 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 108 | lcd.printf("B.Config Alarma"); |
Jesse | 0:8471537b0784 | 109 | wait(2); |
Jesse | 0:8471537b0784 | 110 | |
Jesse | 0:8471537b0784 | 111 | |
Jesse | 0:8471537b0784 | 112 | while(1) |
Jesse | 0:8471537b0784 | 113 | { |
Jesse | 0:8471537b0784 | 114 | |
Jesse | 0:8471537b0784 | 115 | if(Read==1) |
Jesse | 0:8471537b0784 | 116 | { |
Jesse | 0:8471537b0784 | 117 | flag2=0; |
Jesse | 0:8471537b0784 | 118 | if(Menu==1) |
Jesse | 0:8471537b0784 | 119 | { |
Jesse | 0:8471537b0784 | 120 | lcd.cls(); |
Jesse | 0:8471537b0784 | 121 | lcd.printf("Ingrese el Dia"); |
Jesse | 0:8471537b0784 | 122 | wait(0.1); |
Jesse | 0:8471537b0784 | 123 | } |
Jesse | 0:8471537b0784 | 124 | if(Menu==2) |
Jesse | 0:8471537b0784 | 125 | { |
Jesse | 0:8471537b0784 | 126 | lcd.cls(); |
Jesse | 0:8471537b0784 | 127 | lcd.printf("Ingrese la Hora"); |
Jesse | 0:8471537b0784 | 128 | wait(0.1); |
Jesse | 0:8471537b0784 | 129 | } |
Jesse | 0:8471537b0784 | 130 | if(Menu==3) |
Jesse | 0:8471537b0784 | 131 | { |
Jesse | 0:8471537b0784 | 132 | lcd.cls(); |
Jesse | 0:8471537b0784 | 133 | lcd.printf("Ingrese Minutos"); |
Jesse | 0:8471537b0784 | 134 | wait(0.1); |
Jesse | 0:8471537b0784 | 135 | } |
Jesse | 0:8471537b0784 | 136 | if(Menu==4) |
Jesse | 0:8471537b0784 | 137 | { |
Jesse | 0:8471537b0784 | 138 | lcd.cls(); |
Jesse | 0:8471537b0784 | 139 | lcd.printf(" Guardados !"); |
Jesse | 0:8471537b0784 | 140 | wait(0.1); |
Jesse | 0:8471537b0784 | 141 | wait(1); |
Jesse | 0:8471537b0784 | 142 | lcd.cls(); |
Jesse | 0:8471537b0784 | 143 | lcd.printf(".....En breve..... "); |
Jesse | 0:8471537b0784 | 144 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 145 | lcd.printf(".....La Hora!...."); |
Jesse | 0:8471537b0784 | 146 | wait(2); |
Jesse | 0:8471537b0784 | 147 | lcd.cls(); |
Jesse | 0:8471537b0784 | 148 | Menu=0; |
Jesse | 0:8471537b0784 | 149 | flag2=1; |
Jesse | 0:8471537b0784 | 150 | Read=0; |
Jesse | 0:8471537b0784 | 151 | } |
Jesse | 0:8471537b0784 | 152 | |
Jesse | 0:8471537b0784 | 153 | if(Aumen2==1) |
Jesse | 0:8471537b0784 | 154 | { |
Jesse | 0:8471537b0784 | 155 | flag2=0; |
Jesse | 0:8471537b0784 | 156 | Aumen2=0; |
Jesse | 0:8471537b0784 | 157 | if(Menu==3) |
Jesse | 0:8471537b0784 | 158 | { |
Jesse | 0:8471537b0784 | 159 | if(c<59) |
Jesse | 0:8471537b0784 | 160 | { |
Jesse | 0:8471537b0784 | 161 | lcd.cls(); |
Jesse | 0:8471537b0784 | 162 | c=c+1; |
Jesse | 0:8471537b0784 | 163 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 164 | lcd.printf("Minutos: %d",c); |
Jesse | 0:8471537b0784 | 165 | wait(0.1); |
Jesse | 0:8471537b0784 | 166 | } |
Jesse | 0:8471537b0784 | 167 | else |
Jesse | 0:8471537b0784 | 168 | { |
Jesse | 0:8471537b0784 | 169 | c=0; |
Jesse | 0:8471537b0784 | 170 | } |
Jesse | 0:8471537b0784 | 171 | } |
Jesse | 0:8471537b0784 | 172 | if(Menu==2) |
Jesse | 0:8471537b0784 | 173 | { |
Jesse | 0:8471537b0784 | 174 | if(d<23) |
Jesse | 0:8471537b0784 | 175 | { |
Jesse | 0:8471537b0784 | 176 | lcd.cls(); |
Jesse | 0:8471537b0784 | 177 | d=d+1; |
Jesse | 0:8471537b0784 | 178 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 179 | lcd.printf("Horas %d",d); |
Jesse | 0:8471537b0784 | 180 | wait(0.1); |
Jesse | 0:8471537b0784 | 181 | } |
Jesse | 0:8471537b0784 | 182 | else |
Jesse | 0:8471537b0784 | 183 | { |
Jesse | 0:8471537b0784 | 184 | d=0; |
Jesse | 0:8471537b0784 | 185 | } |
Jesse | 0:8471537b0784 | 186 | } |
Jesse | 0:8471537b0784 | 187 | if(Menu==1) |
Jesse | 0:8471537b0784 | 188 | { |
Jesse | 0:8471537b0784 | 189 | if(e<7) |
Jesse | 0:8471537b0784 | 190 | { |
Jesse | 0:8471537b0784 | 191 | lcd.cls(); |
Jesse | 0:8471537b0784 | 192 | e=e+1; |
Jesse | 0:8471537b0784 | 193 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 194 | lcd.printf("Dia: %d",e); |
Jesse | 0:8471537b0784 | 195 | wait(0.1); |
Jesse | 0:8471537b0784 | 196 | } |
Jesse | 0:8471537b0784 | 197 | else |
Jesse | 0:8471537b0784 | 198 | { |
Jesse | 0:8471537b0784 | 199 | e=0; |
Jesse | 0:8471537b0784 | 200 | } |
Jesse | 0:8471537b0784 | 201 | } |
Jesse | 0:8471537b0784 | 202 | } |
Jesse | 0:8471537b0784 | 203 | |
Jesse | 0:8471537b0784 | 204 | if(Decre2==1) |
Jesse | 0:8471537b0784 | 205 | { |
Jesse | 0:8471537b0784 | 206 | flag2=0; |
Jesse | 0:8471537b0784 | 207 | Decre2=0; |
Jesse | 0:8471537b0784 | 208 | if(Menu==3) |
Jesse | 0:8471537b0784 | 209 | { |
Jesse | 0:8471537b0784 | 210 | if(c>0) |
Jesse | 0:8471537b0784 | 211 | { |
Jesse | 0:8471537b0784 | 212 | lcd.cls(); |
Jesse | 0:8471537b0784 | 213 | c=c-1; |
Jesse | 0:8471537b0784 | 214 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 215 | lcd.printf("Minutos: %d",c); |
Jesse | 0:8471537b0784 | 216 | wait(0.1); |
Jesse | 0:8471537b0784 | 217 | } |
Jesse | 0:8471537b0784 | 218 | else |
Jesse | 0:8471537b0784 | 219 | { |
Jesse | 0:8471537b0784 | 220 | c=0; |
Jesse | 0:8471537b0784 | 221 | } |
Jesse | 0:8471537b0784 | 222 | } |
Jesse | 0:8471537b0784 | 223 | if(Menu==2) |
Jesse | 0:8471537b0784 | 224 | { |
Jesse | 0:8471537b0784 | 225 | if(d>0) |
Jesse | 0:8471537b0784 | 226 | { |
Jesse | 0:8471537b0784 | 227 | lcd.cls(); |
Jesse | 0:8471537b0784 | 228 | d=d-1; |
Jesse | 0:8471537b0784 | 229 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 230 | lcd.printf("Hora: %d",d); |
Jesse | 0:8471537b0784 | 231 | wait(0.1); |
Jesse | 0:8471537b0784 | 232 | } |
Jesse | 0:8471537b0784 | 233 | else |
Jesse | 0:8471537b0784 | 234 | { |
Jesse | 0:8471537b0784 | 235 | d=0; |
Jesse | 0:8471537b0784 | 236 | } |
Jesse | 0:8471537b0784 | 237 | } |
Jesse | 0:8471537b0784 | 238 | if(Menu==1) |
Jesse | 0:8471537b0784 | 239 | { |
Jesse | 0:8471537b0784 | 240 | if(e>0) |
Jesse | 0:8471537b0784 | 241 | { |
Jesse | 0:8471537b0784 | 242 | lcd.cls(); |
Jesse | 0:8471537b0784 | 243 | e=e-1; |
Jesse | 0:8471537b0784 | 244 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 245 | lcd.printf("Dia: %d",e); |
Jesse | 0:8471537b0784 | 246 | wait(0.1); |
Jesse | 0:8471537b0784 | 247 | } |
Jesse | 0:8471537b0784 | 248 | else |
Jesse | 0:8471537b0784 | 249 | { |
Jesse | 0:8471537b0784 | 250 | e=0; |
Jesse | 0:8471537b0784 | 251 | } |
Jesse | 0:8471537b0784 | 252 | } |
Jesse | 0:8471537b0784 | 253 | |
Jesse | 0:8471537b0784 | 254 | } |
Jesse | 0:8471537b0784 | 255 | |
Jesse | 0:8471537b0784 | 256 | } |
Jesse | 0:8471537b0784 | 257 | if(Write==1) |
Jesse | 0:8471537b0784 | 258 | { |
Jesse | 0:8471537b0784 | 259 | if(Menu==1) |
Jesse | 0:8471537b0784 | 260 | { |
Jesse | 0:8471537b0784 | 261 | lcd.cls(); |
Jesse | 0:8471537b0784 | 262 | lcd.printf("Ingrese Hora"); |
Jesse | 0:8471537b0784 | 263 | wait(0.1); |
Jesse | 0:8471537b0784 | 264 | } |
Jesse | 0:8471537b0784 | 265 | if(Menu==2) |
Jesse | 0:8471537b0784 | 266 | { |
Jesse | 0:8471537b0784 | 267 | lcd.cls(); |
Jesse | 0:8471537b0784 | 268 | lcd.printf("Ingrese Min"); |
Jesse | 0:8471537b0784 | 269 | wait(0.1); |
Jesse | 0:8471537b0784 | 270 | } |
Jesse | 0:8471537b0784 | 271 | if(Menu==3) |
Jesse | 0:8471537b0784 | 272 | { |
Jesse | 0:8471537b0784 | 273 | lcd.cls(); |
Jesse | 0:8471537b0784 | 274 | lcd.printf("Ingrese Seg)"); |
Jesse | 0:8471537b0784 | 275 | wait(0.1); |
Jesse | 0:8471537b0784 | 276 | } |
Jesse | 0:8471537b0784 | 277 | if(Menu==4) |
Jesse | 0:8471537b0784 | 278 | { |
Jesse | 0:8471537b0784 | 279 | lcd.cls(); |
Jesse | 0:8471537b0784 | 280 | lcd.printf("Dia semana(1-7)"); |
Jesse | 0:8471537b0784 | 281 | wait(0.1); |
Jesse | 0:8471537b0784 | 282 | } |
Jesse | 0:8471537b0784 | 283 | if(Menu==5) |
Jesse | 0:8471537b0784 | 284 | { |
Jesse | 0:8471537b0784 | 285 | lcd.cls(); |
Jesse | 0:8471537b0784 | 286 | lcd.printf("Ingrese Dia"); |
Jesse | 0:8471537b0784 | 287 | wait(0.1); |
Jesse | 0:8471537b0784 | 288 | } |
Jesse | 0:8471537b0784 | 289 | if(Menu==6) |
Jesse | 0:8471537b0784 | 290 | { |
Jesse | 0:8471537b0784 | 291 | lcd.cls(); |
Jesse | 0:8471537b0784 | 292 | lcd.printf("Ingrese Mes"); |
Jesse | 0:8471537b0784 | 293 | wait(0.1); |
Jesse | 0:8471537b0784 | 294 | } |
Jesse | 0:8471537b0784 | 295 | if(Menu==7) |
Jesse | 0:8471537b0784 | 296 | { |
Jesse | 0:8471537b0784 | 297 | lcd.cls(); |
Jesse | 0:8471537b0784 | 298 | lcd.printf("Ingrese Ano"); |
Jesse | 0:8471537b0784 | 299 | wait(0.1); |
Jesse | 0:8471537b0784 | 300 | } |
Jesse | 0:8471537b0784 | 301 | if(Menu==8) |
Jesse | 0:8471537b0784 | 302 | { |
Jesse | 0:8471537b0784 | 303 | lcd.cls(); |
Jesse | 0:8471537b0784 | 304 | lcd.printf(" Datos Guardados!"); |
Jesse | 0:8471537b0784 | 305 | wait(1); |
Jesse | 0:8471537b0784 | 306 | Menu=0; |
Jesse | 0:8471537b0784 | 307 | lcd.cls(); |
Jesse | 0:8471537b0784 | 308 | rtc.setTime(tm, false, false); |
Jesse | 0:8471537b0784 | 309 | rtc.startClock(); |
Jesse | 0:8471537b0784 | 310 | wait(0.2); |
Jesse | 0:8471537b0784 | 311 | flag2=1; |
Jesse | 0:8471537b0784 | 312 | lcd.cls(); |
Jesse | 0:8471537b0784 | 313 | lcd.printf(".....En breve...."); |
Jesse | 0:8471537b0784 | 314 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 315 | lcd.printf(".....La Hora!...."); |
Jesse | 0:8471537b0784 | 316 | wait(2); |
Jesse | 0:8471537b0784 | 317 | lcd.cls(); |
Jesse | 0:8471537b0784 | 318 | Write=0; |
Jesse | 0:8471537b0784 | 319 | } |
Jesse | 0:8471537b0784 | 320 | } |
Jesse | 0:8471537b0784 | 321 | |
Jesse | 0:8471537b0784 | 322 | if(Aumen2==1) |
Jesse | 0:8471537b0784 | 323 | { |
Jesse | 0:8471537b0784 | 324 | Aumen2=0; |
Jesse | 0:8471537b0784 | 325 | if(Menu==1) |
Jesse | 0:8471537b0784 | 326 | { |
Jesse | 0:8471537b0784 | 327 | lcd.cls(); |
Jesse | 0:8471537b0784 | 328 | lcd.printf("Ingrese Hora"); |
Jesse | 0:8471537b0784 | 329 | if(tm.hour<23) |
Jesse | 0:8471537b0784 | 330 | { |
Jesse | 0:8471537b0784 | 331 | tm.hour=tm.hour+1; |
Jesse | 0:8471537b0784 | 332 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 333 | lcd.printf("Hora:%d",tm.hour); |
Jesse | 0:8471537b0784 | 334 | wait(0.2); |
Jesse | 0:8471537b0784 | 335 | } |
Jesse | 0:8471537b0784 | 336 | else |
Jesse | 0:8471537b0784 | 337 | { |
Jesse | 0:8471537b0784 | 338 | Hora=0; |
Jesse | 0:8471537b0784 | 339 | } |
Jesse | 0:8471537b0784 | 340 | } |
Jesse | 0:8471537b0784 | 341 | if(Menu==2) |
Jesse | 0:8471537b0784 | 342 | { |
Jesse | 0:8471537b0784 | 343 | lcd.cls(); |
Jesse | 0:8471537b0784 | 344 | lcd.printf("Ingrese Min"); |
Jesse | 0:8471537b0784 | 345 | if(tm.min<59) |
Jesse | 0:8471537b0784 | 346 | { |
Jesse | 0:8471537b0784 | 347 | tm.min=tm.min+1; |
Jesse | 0:8471537b0784 | 348 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 349 | lcd.printf("Minutos:%d",tm.min); |
Jesse | 0:8471537b0784 | 350 | wait(0.2); |
Jesse | 0:8471537b0784 | 351 | } |
Jesse | 0:8471537b0784 | 352 | else |
Jesse | 0:8471537b0784 | 353 | { |
Jesse | 0:8471537b0784 | 354 | Minuto=0; |
Jesse | 0:8471537b0784 | 355 | } |
Jesse | 0:8471537b0784 | 356 | } |
Jesse | 0:8471537b0784 | 357 | if(Menu==3) |
Jesse | 0:8471537b0784 | 358 | { |
Jesse | 0:8471537b0784 | 359 | lcd.cls(); |
Jesse | 0:8471537b0784 | 360 | lcd.printf("Ingrese Seg"); |
Jesse | 0:8471537b0784 | 361 | if(tm.sec<59) |
Jesse | 0:8471537b0784 | 362 | { |
Jesse | 0:8471537b0784 | 363 | tm.sec=tm.sec+1; |
Jesse | 0:8471537b0784 | 364 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 365 | lcd.printf("Segundos:%d",tm.sec); |
Jesse | 0:8471537b0784 | 366 | wait(0.2); |
Jesse | 0:8471537b0784 | 367 | } |
Jesse | 0:8471537b0784 | 368 | else |
Jesse | 0:8471537b0784 | 369 | { |
Jesse | 0:8471537b0784 | 370 | Segundo=0; |
Jesse | 0:8471537b0784 | 371 | } |
Jesse | 0:8471537b0784 | 372 | } |
Jesse | 0:8471537b0784 | 373 | if(Menu==4) |
Jesse | 0:8471537b0784 | 374 | { |
Jesse | 0:8471537b0784 | 375 | if(tm.wday<7) |
Jesse | 0:8471537b0784 | 376 | { |
Jesse | 0:8471537b0784 | 377 | tm.wday=tm.wday+1; |
Jesse | 0:8471537b0784 | 378 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 379 | lcd.printf("Dia:%d",tm.wday); |
Jesse | 0:8471537b0784 | 380 | wait(0.2); |
Jesse | 0:8471537b0784 | 381 | } |
Jesse | 0:8471537b0784 | 382 | else |
Jesse | 0:8471537b0784 | 383 | { |
Jesse | 0:8471537b0784 | 384 | Dia=0; |
Jesse | 0:8471537b0784 | 385 | } |
Jesse | 0:8471537b0784 | 386 | } |
Jesse | 0:8471537b0784 | 387 | if(Menu==5) |
Jesse | 0:8471537b0784 | 388 | { |
Jesse | 0:8471537b0784 | 389 | lcd.cls(); |
Jesse | 0:8471537b0784 | 390 | lcd.printf("Ingrese Dia"); |
Jesse | 0:8471537b0784 | 391 | if(Dya<31) |
Jesse | 0:8471537b0784 | 392 | { |
Jesse | 0:8471537b0784 | 393 | tm.date=tm.date+1; |
Jesse | 0:8471537b0784 | 394 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 395 | lcd.printf("Dia:%d",tm.date); |
Jesse | 0:8471537b0784 | 396 | wait(0.2); |
Jesse | 0:8471537b0784 | 397 | } |
Jesse | 0:8471537b0784 | 398 | else |
Jesse | 0:8471537b0784 | 399 | { |
Jesse | 0:8471537b0784 | 400 | Dya=0; |
Jesse | 0:8471537b0784 | 401 | } |
Jesse | 0:8471537b0784 | 402 | } |
Jesse | 0:8471537b0784 | 403 | if(Menu==6) |
Jesse | 0:8471537b0784 | 404 | { |
Jesse | 0:8471537b0784 | 405 | lcd.cls(); |
Jesse | 0:8471537b0784 | 406 | lcd.printf("Ingrese Mes"); |
Jesse | 0:8471537b0784 | 407 | if(tm.mon<12) |
Jesse | 0:8471537b0784 | 408 | { |
Jesse | 0:8471537b0784 | 409 | tm.mon=tm.mon+1; |
Jesse | 0:8471537b0784 | 410 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 411 | lcd.printf("Mes:%d",tm.mon); |
Jesse | 0:8471537b0784 | 412 | wait(0.2); |
Jesse | 0:8471537b0784 | 413 | } |
Jesse | 0:8471537b0784 | 414 | else |
Jesse | 0:8471537b0784 | 415 | { |
Jesse | 0:8471537b0784 | 416 | Mes=0; |
Jesse | 0:8471537b0784 | 417 | } |
Jesse | 0:8471537b0784 | 418 | } |
Jesse | 0:8471537b0784 | 419 | if(Menu==7) |
Jesse | 0:8471537b0784 | 420 | { |
Jesse | 0:8471537b0784 | 421 | lcd.cls(); |
Jesse | 0:8471537b0784 | 422 | lcd.printf("Ingrese Ano"); |
Jesse | 0:8471537b0784 | 423 | Anno=Anno+1; |
Jesse | 0:8471537b0784 | 424 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 425 | lcd.printf("Ano:%d",Anno); |
Jesse | 0:8471537b0784 | 426 | wait(0.2); |
Jesse | 0:8471537b0784 | 427 | tm.year=Anno; |
Jesse | 0:8471537b0784 | 428 | } |
Jesse | 0:8471537b0784 | 429 | |
Jesse | 0:8471537b0784 | 430 | } |
Jesse | 0:8471537b0784 | 431 | if(Decre2==1) |
Jesse | 0:8471537b0784 | 432 | { |
Jesse | 0:8471537b0784 | 433 | Decre2=0; |
Jesse | 0:8471537b0784 | 434 | |
Jesse | 0:8471537b0784 | 435 | if(Menu==1) |
Jesse | 0:8471537b0784 | 436 | { |
Jesse | 0:8471537b0784 | 437 | if(tm.hour>0) |
Jesse | 0:8471537b0784 | 438 | { |
Jesse | 0:8471537b0784 | 439 | tm.hour=tm.hour-1; |
Jesse | 0:8471537b0784 | 440 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 441 | lcd.printf("Hora:%d",tm.hour); |
Jesse | 0:8471537b0784 | 442 | wait(0.1); |
Jesse | 0:8471537b0784 | 443 | } |
Jesse | 0:8471537b0784 | 444 | } |
Jesse | 0:8471537b0784 | 445 | if(Menu==2) |
Jesse | 0:8471537b0784 | 446 | { |
Jesse | 0:8471537b0784 | 447 | if(tm.min>0) |
Jesse | 0:8471537b0784 | 448 | { |
Jesse | 0:8471537b0784 | 449 | tm.min=tm.min-1; |
Jesse | 0:8471537b0784 | 450 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 451 | lcd.printf("Minutos:%d",tm.min); |
Jesse | 0:8471537b0784 | 452 | wait(0.1); |
Jesse | 0:8471537b0784 | 453 | } |
Jesse | 0:8471537b0784 | 454 | } |
Jesse | 0:8471537b0784 | 455 | if(Menu==3) |
Jesse | 0:8471537b0784 | 456 | { |
Jesse | 0:8471537b0784 | 457 | if(tm.sec>0) |
Jesse | 0:8471537b0784 | 458 | { |
Jesse | 0:8471537b0784 | 459 | tm.sec=tm.sec-1; |
Jesse | 0:8471537b0784 | 460 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 461 | lcd.printf("Segundos:%d",tm.sec); |
Jesse | 0:8471537b0784 | 462 | wait(0.1); |
Jesse | 0:8471537b0784 | 463 | } |
Jesse | 0:8471537b0784 | 464 | } |
Jesse | 0:8471537b0784 | 465 | if(Menu==4) |
Jesse | 0:8471537b0784 | 466 | { |
Jesse | 0:8471537b0784 | 467 | if(tm.wday>0) |
Jesse | 0:8471537b0784 | 468 | { |
Jesse | 0:8471537b0784 | 469 | tm.wday=tm.wday-1; |
Jesse | 0:8471537b0784 | 470 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 471 | lcd.printf("Dia:%d",tm.wday); |
Jesse | 0:8471537b0784 | 472 | wait(0.1); |
Jesse | 0:8471537b0784 | 473 | } |
Jesse | 0:8471537b0784 | 474 | } |
Jesse | 0:8471537b0784 | 475 | if(Menu==5) |
Jesse | 0:8471537b0784 | 476 | { |
Jesse | 0:8471537b0784 | 477 | if(tm.date>0) |
Jesse | 0:8471537b0784 | 478 | { |
Jesse | 0:8471537b0784 | 479 | tm.date=tm.date-1; |
Jesse | 0:8471537b0784 | 480 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 481 | lcd.printf("Dia:%d",tm.date); |
Jesse | 0:8471537b0784 | 482 | wait(0.1); |
Jesse | 0:8471537b0784 | 483 | } |
Jesse | 0:8471537b0784 | 484 | } |
Jesse | 0:8471537b0784 | 485 | if(Menu==6) |
Jesse | 0:8471537b0784 | 486 | { |
Jesse | 0:8471537b0784 | 487 | if(tm.mon>0) |
Jesse | 0:8471537b0784 | 488 | { |
Jesse | 0:8471537b0784 | 489 | tm.mon=tm.mon-1; |
Jesse | 0:8471537b0784 | 490 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 491 | lcd.printf("Mes:%d",tm.mon); |
Jesse | 0:8471537b0784 | 492 | wait(0.1); |
Jesse | 0:8471537b0784 | 493 | } |
Jesse | 0:8471537b0784 | 494 | } |
Jesse | 0:8471537b0784 | 495 | if(Menu==7) |
Jesse | 0:8471537b0784 | 496 | { |
Jesse | 0:8471537b0784 | 497 | if(Anno>0) |
Jesse | 0:8471537b0784 | 498 | { |
Jesse | 0:8471537b0784 | 499 | Anno=Anno-1; |
Jesse | 0:8471537b0784 | 500 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 501 | lcd.printf("Ano:%d",Anno); |
Jesse | 0:8471537b0784 | 502 | wait(0.1); |
Jesse | 0:8471537b0784 | 503 | tm.year=Anno; |
Jesse | 0:8471537b0784 | 504 | } |
Jesse | 0:8471537b0784 | 505 | } |
Jesse | 0:8471537b0784 | 506 | |
Jesse | 0:8471537b0784 | 507 | } |
Jesse | 0:8471537b0784 | 508 | |
Jesse | 0:8471537b0784 | 509 | if((flag2==1)&&(Write==0)&&(Read==0)&&(Menu==0)) |
Jesse | 0:8471537b0784 | 510 | { |
Jesse | 0:8471537b0784 | 511 | rtc.getTime(tm); |
Jesse | 0:8471537b0784 | 512 | lcd.cls(); |
Jesse | 0:8471537b0784 | 513 | lcd.locate(0,1); // Print and refresh data on line 2 of the LCD display |
Jesse | 0:8471537b0784 | 514 | lcd.printf("%.2D",tm.hour); |
Jesse | 0:8471537b0784 | 515 | lcd.printf(":%.2D",tm.min); |
Jesse | 0:8471537b0784 | 516 | lcd.printf(":%.2D",tm.sec); |
Jesse | 0:8471537b0784 | 517 | lcd.locate(0,0); |
Jesse | 0:8471537b0784 | 518 | lcd.printf("%.2D",tm.mon); |
Jesse | 0:8471537b0784 | 519 | lcd.printf("/%.2D",tm.date); |
Jesse | 0:8471537b0784 | 520 | lcd.printf("/%.2D",Anno); |
Jesse | 0:8471537b0784 | 521 | |
Jesse | 0:8471537b0784 | 522 | |
Jesse | 0:8471537b0784 | 523 | if (tm.wday == 6){ |
Jesse | 0:8471537b0784 | 524 | lcd.printf(" Frid\n"); |
Jesse | 0:8471537b0784 | 525 | wait(0.2);} |
Jesse | 0:8471537b0784 | 526 | if (tm.wday == 7){ |
Jesse | 0:8471537b0784 | 527 | lcd.printf(" Sat\n"); |
Jesse | 0:8471537b0784 | 528 | wait(0.2);} |
Jesse | 0:8471537b0784 | 529 | if (tm.wday == 1){ |
Jesse | 0:8471537b0784 | 530 | lcd.printf(" Sun\n"); |
Jesse | 0:8471537b0784 | 531 | wait(0.2);} |
Jesse | 0:8471537b0784 | 532 | if (tm.wday == 2){ |
Jesse | 0:8471537b0784 | 533 | lcd.printf(" Mon\n"); |
Jesse | 0:8471537b0784 | 534 | wait(0.2);} |
Jesse | 0:8471537b0784 | 535 | if (tm.wday == 3){ |
Jesse | 0:8471537b0784 | 536 | lcd.printf(" Tues\n"); |
Jesse | 0:8471537b0784 | 537 | wait(0.2);} |
Jesse | 0:8471537b0784 | 538 | if (tm.wday == 4){ |
Jesse | 0:8471537b0784 | 539 | lcd.printf(" Wed\n"); |
Jesse | 0:8471537b0784 | 540 | wait(0.2);} |
Jesse | 0:8471537b0784 | 541 | if (tm.wday == 5){ |
Jesse | 0:8471537b0784 | 542 | lcd.printf(" Thur\n"); |
Jesse | 0:8471537b0784 | 543 | wait(0.2);} |
Jesse | 0:8471537b0784 | 544 | wait(0.1); |
Jesse | 0:8471537b0784 | 545 | } |
Jesse | 0:8471537b0784 | 546 | |
Jesse | 0:8471537b0784 | 547 | //Momento para la Alarma |
Jesse | 0:8471537b0784 | 548 | if((tm.hour==d)&(tm.min==c)&(tm.wday==e)&&(tm.hour!=0)&&(Write==0)&&(Read==0)&&(Menu==0)) |
Jesse | 0:8471537b0784 | 549 | { |
Jesse | 0:8471537b0784 | 550 | flag=1; |
Jesse | 0:8471537b0784 | 551 | } |
Jesse | 0:8471537b0784 | 552 | if(flag==1) |
Jesse | 0:8471537b0784 | 553 | { |
Jesse | 0:8471537b0784 | 554 | PWMmodule(ppp,Dd); |
Jesse | 0:8471537b0784 | 555 | flag2=0; |
Jesse | 0:8471537b0784 | 556 | lcd.cls(); |
Jesse | 0:8471537b0784 | 557 | lcd.printf(" Alarma!!"); |
Jesse | 0:8471537b0784 | 558 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 559 | lcd.printf("*.Pos #.Desact"); |
Jesse | 0:8471537b0784 | 560 | if(Aumen2==1) |
Jesse | 0:8471537b0784 | 561 | { |
Jesse | 0:8471537b0784 | 562 | Aumen2=0; |
Jesse | 0:8471537b0784 | 563 | lcd.cls(); |
Jesse | 0:8471537b0784 | 564 | lcd.printf("Se pospone 1min"); |
Jesse | 0:8471537b0784 | 565 | wait(1); |
Jesse | 0:8471537b0784 | 566 | c=c+2; |
Jesse | 0:8471537b0784 | 567 | flag=0; |
Jesse | 0:8471537b0784 | 568 | flag2=1; |
Jesse | 0:8471537b0784 | 569 | } |
Jesse | 0:8471537b0784 | 570 | |
Jesse | 0:8471537b0784 | 571 | if(Decre2==1) |
Jesse | 0:8471537b0784 | 572 | { |
Jesse | 0:8471537b0784 | 573 | |
Jesse | 0:8471537b0784 | 574 | lcd.cls(); |
Jesse | 0:8471537b0784 | 575 | lcd.printf("Se ha desactivado"); |
Jesse | 0:8471537b0784 | 576 | lcd.locate(0,1); |
Jesse | 0:8471537b0784 | 577 | lcd.printf(" la Alarma"); |
Jesse | 0:8471537b0784 | 578 | wait(1); |
Jesse | 0:8471537b0784 | 579 | flag=0; |
Jesse | 0:8471537b0784 | 580 | flag2=1; |
Jesse | 0:8471537b0784 | 581 | d=0; |
Jesse | 0:8471537b0784 | 582 | c=0; |
Jesse | 0:8471537b0784 | 583 | e=0; |
Jesse | 0:8471537b0784 | 584 | Decre2=0; |
Jesse | 0:8471537b0784 | 585 | } |
Jesse | 0:8471537b0784 | 586 | } |
Jesse | 0:8471537b0784 | 587 | } |
Jesse | 0:8471537b0784 | 588 | } |