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