trabajo de creacion de un despertador por i2c configurado por un encoder
Dependencies: DebouncedIn QEI RTC-DS1307 mbed
Fork of I2C by
main.cpp@3:9e5e0b8d0e2a, 2015-11-20 (annotated)
- Committer:
- demo71
- Date:
- Fri Nov 20 03:48:18 2015 +0000
- Revision:
- 3:9e5e0b8d0e2a
- Parent:
- 2:3be003301107
- Child:
- 4:fa48e78e9bba
I2C
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leihen | 0:431183c5b136 | 1 | #include "mbed.h" |
leihen | 0:431183c5b136 | 2 | #include "Rtc_Ds1307.h" |
demo71 | 3:9e5e0b8d0e2a | 3 | #include "DebouncedIn.h" |
demo71 | 3:9e5e0b8d0e2a | 4 | #include "QEI.h" |
leihen | 0:431183c5b136 | 5 | |
leihen | 2:3be003301107 | 6 | //RtcCls rtc(p28, p27, p29, true); |
demo71 | 3:9e5e0b8d0e2a | 7 | Rtc_Ds1307 rtc(PTE0,PTE1); |
leihen | 0:431183c5b136 | 8 | |
leihen | 0:431183c5b136 | 9 | Serial pc(USBTX, USBRX, "pc"); |
leihen | 0:431183c5b136 | 10 | |
demo71 | 3:9e5e0b8d0e2a | 11 | //Configuracion encoder |
demo71 | 3:9e5e0b8d0e2a | 12 | QEI wheel (PTD5, PTD0, NC, 100); |
demo71 | 3:9e5e0b8d0e2a | 13 | |
demo71 | 3:9e5e0b8d0e2a | 14 | //Botones |
demo71 | 3:9e5e0b8d0e2a | 15 | DebouncedIn BotonENC(PTA13); //Boton Encoder |
demo71 | 3:9e5e0b8d0e2a | 16 | |
demo71 | 3:9e5e0b8d0e2a | 17 | DebouncedIn Boton2(PTE20); //Boton para confirmar |
demo71 | 3:9e5e0b8d0e2a | 18 | |
demo71 | 3:9e5e0b8d0e2a | 19 | //salida led |
demo71 | 3:9e5e0b8d0e2a | 20 | DigitalOut myled(PTE21); |
demo71 | 3:9e5e0b8d0e2a | 21 | int dia=0,mes=0,ano=2015,hh=0,mm=0,ss=0; |
demo71 | 3:9e5e0b8d0e2a | 22 | |
leihen | 0:431183c5b136 | 23 | char buffer[128]; |
leihen | 0:431183c5b136 | 24 | int readptr = 0; |
demo71 | 3:9e5e0b8d0e2a | 25 | int start=0; |
demo71 | 3:9e5e0b8d0e2a | 26 | int Config; |
leihen | 1:6dbe51fe0737 | 27 | |
leihen | 0:431183c5b136 | 28 | int main() { |
leihen | 0:431183c5b136 | 29 | char c; |
leihen | 2:3be003301107 | 30 | Rtc_Ds1307::Time_rtc tm = {}; |
leihen | 0:431183c5b136 | 31 | |
leihen | 0:431183c5b136 | 32 | while(1) { |
demo71 | 3:9e5e0b8d0e2a | 33 | |
demo71 | 3:9e5e0b8d0e2a | 34 | set_reloj: |
demo71 | 3:9e5e0b8d0e2a | 35 | |
leihen | 0:431183c5b136 | 36 | pc.printf("*************************************\n"); |
leihen | 0:431183c5b136 | 37 | pc.printf("* Menu for RTC Test : *\n"); |
leihen | 0:431183c5b136 | 38 | pc.printf("* read - reads the clock *\n"); |
leihen | 0:431183c5b136 | 39 | pc.printf("* start - start the clock *\n"); |
leihen | 0:431183c5b136 | 40 | pc.printf("* stop - stop the clock *\n"); |
leihen | 1:6dbe51fe0737 | 41 | pc.printf("* write - write the clock *\n"); |
leihen | 1:6dbe51fe0737 | 42 | pc.printf("* ena - enable Square wave output *\n"); |
leihen | 1:6dbe51fe0737 | 43 | pc.printf("* dis - disable square wave outp. *\n"); |
leihen | 0:431183c5b136 | 44 | pc.printf("*************************************\n"); |
leihen | 0:431183c5b136 | 45 | |
leihen | 0:431183c5b136 | 46 | while( (c = pc.getc()) != '\n') { |
leihen | 0:431183c5b136 | 47 | buffer[readptr++] = c; |
leihen | 0:431183c5b136 | 48 | } |
leihen | 0:431183c5b136 | 49 | buffer[readptr++] = 0; |
leihen | 0:431183c5b136 | 50 | if (strncmp(buffer, "read", 4) == 0) { |
leihen | 0:431183c5b136 | 51 | // perform read |
leihen | 0:431183c5b136 | 52 | pc.printf("Performing read operation\n"); |
leihen | 0:431183c5b136 | 53 | if (rtc.getTime(tm) ) { |
leihen | 0:431183c5b136 | 54 | pc.printf("The current time is : %02d:%02d:%02d\n", tm.hour, tm.min, tm.sec); |
leihen | 1:6dbe51fe0737 | 55 | pc.printf("The current date is : %s, %02d/%02d/%04d\n", rtc.weekdayToString(tm.wday), tm.mon, tm.date, tm.year); |
leihen | 0:431183c5b136 | 56 | } |
leihen | 0:431183c5b136 | 57 | |
leihen | 0:431183c5b136 | 58 | } |
leihen | 0:431183c5b136 | 59 | else if (strncmp(buffer, "write", 5) == 0) { |
leihen | 0:431183c5b136 | 60 | // perform write |
leihen | 1:6dbe51fe0737 | 61 | pc.printf("Enter the date (date 0..31)"); |
leihen | 1:6dbe51fe0737 | 62 | pc.scanf("%d", &tm.date); |
leihen | 1:6dbe51fe0737 | 63 | pc.printf("Enter the date (month 1..12)"); |
leihen | 1:6dbe51fe0737 | 64 | pc.scanf("%d", &tm.mon); |
leihen | 1:6dbe51fe0737 | 65 | pc.printf("Enter the date (year)"); |
leihen | 1:6dbe51fe0737 | 66 | pc.scanf("%d", &tm.year); |
leihen | 1:6dbe51fe0737 | 67 | pc.printf("Enter the time (hours 0..23)"); |
leihen | 1:6dbe51fe0737 | 68 | pc.scanf("%d", &tm.hour); |
leihen | 1:6dbe51fe0737 | 69 | pc.printf("Enter the time (minutes 0..59)"); |
leihen | 1:6dbe51fe0737 | 70 | pc.scanf("%d", &tm.min); |
leihen | 1:6dbe51fe0737 | 71 | pc.printf("Enter the time (seconds 0..59)"); |
leihen | 1:6dbe51fe0737 | 72 | pc.scanf("%d", &tm.sec); |
leihen | 0:431183c5b136 | 73 | pc.printf("Performing write operation\n"); |
leihen | 1:6dbe51fe0737 | 74 | |
leihen | 1:6dbe51fe0737 | 75 | while(pc.readable()) |
leihen | 1:6dbe51fe0737 | 76 | pc.getc(); |
leihen | 1:6dbe51fe0737 | 77 | rtc.setTime(tm, false, false); |
leihen | 0:431183c5b136 | 78 | } |
leihen | 0:431183c5b136 | 79 | else if (strncmp(buffer, "start", 5) == 0) { |
leihen | 0:431183c5b136 | 80 | // start |
demo71 | 3:9e5e0b8d0e2a | 81 | readptr = 0; |
demo71 | 3:9e5e0b8d0e2a | 82 | pc.printf("Dispositivo Iniciado\n"); |
leihen | 1:6dbe51fe0737 | 83 | rtc.startClock(); |
demo71 | 3:9e5e0b8d0e2a | 84 | goto set_prev; |
demo71 | 3:9e5e0b8d0e2a | 85 | |
demo71 | 3:9e5e0b8d0e2a | 86 | |
leihen | 0:431183c5b136 | 87 | } |
leihen | 0:431183c5b136 | 88 | else if (strncmp(buffer, "stop", 4) == 0) { |
leihen | 0:431183c5b136 | 89 | // stop |
leihen | 0:431183c5b136 | 90 | pc.printf("Performing stop operation\n"); |
leihen | 1:6dbe51fe0737 | 91 | rtc.stopClock(); |
leihen | 1:6dbe51fe0737 | 92 | } |
leihen | 1:6dbe51fe0737 | 93 | else if (strncmp(buffer, "ena", 3) == 0) { |
leihen | 1:6dbe51fe0737 | 94 | int rs; |
leihen | 1:6dbe51fe0737 | 95 | pc.printf("Please specify the frequency : [0 = 1Hz, 1 = 4.096kHz, 2 = 8.192kHz, 3 = 32.768kHz] "); |
leihen | 1:6dbe51fe0737 | 96 | scanf("%d", &rs); |
leihen | 1:6dbe51fe0737 | 97 | pc.printf("Enabling the output with %d option\n", rs); |
leihen | 2:3be003301107 | 98 | rtc.setSquareWaveOutput(true, (Rtc_Ds1307::SqwRateSelect_t)rs); |
leihen | 1:6dbe51fe0737 | 99 | } |
leihen | 1:6dbe51fe0737 | 100 | else if (strncmp(buffer, "dis", 3) == 0) { |
leihen | 1:6dbe51fe0737 | 101 | pc.printf("Disableing square wave output\n"); |
leihen | 2:3be003301107 | 102 | rtc.setSquareWaveOutput(false, Rtc_Ds1307::RS1Hz); |
leihen | 0:431183c5b136 | 103 | } |
leihen | 0:431183c5b136 | 104 | else { |
leihen | 0:431183c5b136 | 105 | pc.printf("syntax error\n"); |
leihen | 0:431183c5b136 | 106 | } |
leihen | 0:431183c5b136 | 107 | readptr = 0; |
demo71 | 3:9e5e0b8d0e2a | 108 | //pc.printf("\n\n\n"); |
demo71 | 3:9e5e0b8d0e2a | 109 | } |
demo71 | 3:9e5e0b8d0e2a | 110 | ///////////////////////////////////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 111 | set_prev: |
demo71 | 3:9e5e0b8d0e2a | 112 | pc.printf("Dispositivo Configurado ? ---- 1 = No 2 = Si\n"); |
demo71 | 3:9e5e0b8d0e2a | 113 | pc.scanf("%d", &Config); |
demo71 | 3:9e5e0b8d0e2a | 114 | |
demo71 | 3:9e5e0b8d0e2a | 115 | if (Config ==1){ |
demo71 | 3:9e5e0b8d0e2a | 116 | readptr = 0; |
demo71 | 3:9e5e0b8d0e2a | 117 | goto set_reloj; |
demo71 | 3:9e5e0b8d0e2a | 118 | } |
demo71 | 3:9e5e0b8d0e2a | 119 | |
demo71 | 3:9e5e0b8d0e2a | 120 | |
demo71 | 3:9e5e0b8d0e2a | 121 | else if (Config ==2){ |
demo71 | 3:9e5e0b8d0e2a | 122 | |
demo71 | 3:9e5e0b8d0e2a | 123 | pc.printf("Dispositivo Configurado Correctamente Espere ....\n"); |
demo71 | 3:9e5e0b8d0e2a | 124 | wait(5); |
demo71 | 3:9e5e0b8d0e2a | 125 | goto set_alarma; |
demo71 | 3:9e5e0b8d0e2a | 126 | } |
demo71 | 3:9e5e0b8d0e2a | 127 | else { |
demo71 | 3:9e5e0b8d0e2a | 128 | pc.printf("syntax error\n"); |
demo71 | 3:9e5e0b8d0e2a | 129 | goto set_prev; |
demo71 | 3:9e5e0b8d0e2a | 130 | } |
demo71 | 3:9e5e0b8d0e2a | 131 | /////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 132 | |
demo71 | 3:9e5e0b8d0e2a | 133 | set_alarma: |
demo71 | 3:9e5e0b8d0e2a | 134 | pc.printf("******* Configuracion Alarma *******\n"); |
demo71 | 3:9e5e0b8d0e2a | 135 | |
demo71 | 3:9e5e0b8d0e2a | 136 | |
demo71 | 3:9e5e0b8d0e2a | 137 | set_dia: |
demo71 | 3:9e5e0b8d0e2a | 138 | while(1){ |
demo71 | 3:9e5e0b8d0e2a | 139 | |
demo71 | 3:9e5e0b8d0e2a | 140 | dia=dia+wheel.getPulses(); |
demo71 | 3:9e5e0b8d0e2a | 141 | wheel.reset(); |
demo71 | 3:9e5e0b8d0e2a | 142 | ////////////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 143 | |
demo71 | 3:9e5e0b8d0e2a | 144 | if(dia>=31){ |
demo71 | 3:9e5e0b8d0e2a | 145 | dia=31; |
demo71 | 3:9e5e0b8d0e2a | 146 | } |
demo71 | 3:9e5e0b8d0e2a | 147 | else if (dia<=0){ |
demo71 | 3:9e5e0b8d0e2a | 148 | dia=0; |
demo71 | 3:9e5e0b8d0e2a | 149 | } |
demo71 | 3:9e5e0b8d0e2a | 150 | pc.printf(">Dia=%d Mes=%d Ano=%d Hora=%d Min=%d Seg=%d\n ",dia,mes,ano,hh,mm,ss); |
demo71 | 3:9e5e0b8d0e2a | 151 | |
demo71 | 3:9e5e0b8d0e2a | 152 | |
demo71 | 3:9e5e0b8d0e2a | 153 | if(BotonENC.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 154 | goto set_mes; |
demo71 | 3:9e5e0b8d0e2a | 155 | } |
demo71 | 3:9e5e0b8d0e2a | 156 | if(Boton2.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 157 | goto set_comp; |
demo71 | 3:9e5e0b8d0e2a | 158 | } |
demo71 | 3:9e5e0b8d0e2a | 159 | |
demo71 | 3:9e5e0b8d0e2a | 160 | |
demo71 | 3:9e5e0b8d0e2a | 161 | } |
demo71 | 3:9e5e0b8d0e2a | 162 | |
demo71 | 3:9e5e0b8d0e2a | 163 | set_mes: |
demo71 | 3:9e5e0b8d0e2a | 164 | while(1){ |
demo71 | 3:9e5e0b8d0e2a | 165 | |
demo71 | 3:9e5e0b8d0e2a | 166 | mes=mes+wheel.getPulses(); |
demo71 | 3:9e5e0b8d0e2a | 167 | wheel.reset(); |
demo71 | 3:9e5e0b8d0e2a | 168 | ////////////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 169 | |
demo71 | 3:9e5e0b8d0e2a | 170 | if(mes>=12){ |
demo71 | 3:9e5e0b8d0e2a | 171 | mes=12; |
demo71 | 3:9e5e0b8d0e2a | 172 | } |
demo71 | 3:9e5e0b8d0e2a | 173 | else if (mes<=0){ |
demo71 | 3:9e5e0b8d0e2a | 174 | mes=0; |
demo71 | 3:9e5e0b8d0e2a | 175 | } |
demo71 | 3:9e5e0b8d0e2a | 176 | pc.printf(" Dia=%d >Mes=%d Ano=%d Hora=%d Min=%d Seg=%d\n ",dia,mes,ano,hh,mm,ss); |
demo71 | 3:9e5e0b8d0e2a | 177 | |
demo71 | 3:9e5e0b8d0e2a | 178 | |
demo71 | 3:9e5e0b8d0e2a | 179 | if(BotonENC.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 180 | goto set_ano; |
demo71 | 3:9e5e0b8d0e2a | 181 | } |
demo71 | 3:9e5e0b8d0e2a | 182 | if(Boton2.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 183 | goto set_comp; |
demo71 | 3:9e5e0b8d0e2a | 184 | } |
demo71 | 3:9e5e0b8d0e2a | 185 | |
demo71 | 3:9e5e0b8d0e2a | 186 | |
demo71 | 3:9e5e0b8d0e2a | 187 | } |
demo71 | 3:9e5e0b8d0e2a | 188 | set_ano: |
demo71 | 3:9e5e0b8d0e2a | 189 | while(1){ |
demo71 | 3:9e5e0b8d0e2a | 190 | |
demo71 | 3:9e5e0b8d0e2a | 191 | ano=ano+wheel.getPulses(); |
demo71 | 3:9e5e0b8d0e2a | 192 | wheel.reset(); |
demo71 | 3:9e5e0b8d0e2a | 193 | ////////////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 194 | |
demo71 | 3:9e5e0b8d0e2a | 195 | if(ano>=3000){ |
demo71 | 3:9e5e0b8d0e2a | 196 | ano=3000; |
demo71 | 3:9e5e0b8d0e2a | 197 | } |
demo71 | 3:9e5e0b8d0e2a | 198 | else if (ano<=2015){ |
demo71 | 3:9e5e0b8d0e2a | 199 | ano=2015; |
demo71 | 3:9e5e0b8d0e2a | 200 | } |
demo71 | 3:9e5e0b8d0e2a | 201 | pc.printf(" Dia=%d Mes=%d >Ano=%d Hora=%d Min=%d Seg=%d\n ",dia,mes,ano,hh,mm,ss); |
demo71 | 3:9e5e0b8d0e2a | 202 | |
demo71 | 3:9e5e0b8d0e2a | 203 | |
demo71 | 3:9e5e0b8d0e2a | 204 | if(BotonENC.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 205 | goto set_hh; |
leihen | 0:431183c5b136 | 206 | } |
demo71 | 3:9e5e0b8d0e2a | 207 | if(Boton2.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 208 | goto set_comp; |
demo71 | 3:9e5e0b8d0e2a | 209 | } |
demo71 | 3:9e5e0b8d0e2a | 210 | |
demo71 | 3:9e5e0b8d0e2a | 211 | } |
demo71 | 3:9e5e0b8d0e2a | 212 | set_hh: |
demo71 | 3:9e5e0b8d0e2a | 213 | while(1){ |
demo71 | 3:9e5e0b8d0e2a | 214 | |
demo71 | 3:9e5e0b8d0e2a | 215 | hh=hh+wheel.getPulses(); |
demo71 | 3:9e5e0b8d0e2a | 216 | wheel.reset(); |
demo71 | 3:9e5e0b8d0e2a | 217 | ////////////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 218 | |
demo71 | 3:9e5e0b8d0e2a | 219 | if(hh>=23){ |
demo71 | 3:9e5e0b8d0e2a | 220 | hh=23; |
demo71 | 3:9e5e0b8d0e2a | 221 | } |
demo71 | 3:9e5e0b8d0e2a | 222 | else if (hh<=0){ |
demo71 | 3:9e5e0b8d0e2a | 223 | hh=0; |
demo71 | 3:9e5e0b8d0e2a | 224 | } |
demo71 | 3:9e5e0b8d0e2a | 225 | pc.printf(" Dia=%d Mes=%d Ano=%d >Hora=%d Min=%d Seg=%d\n ",dia,mes,ano,hh,mm,ss); |
demo71 | 3:9e5e0b8d0e2a | 226 | |
demo71 | 3:9e5e0b8d0e2a | 227 | |
demo71 | 3:9e5e0b8d0e2a | 228 | if(BotonENC.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 229 | goto set_mm; |
demo71 | 3:9e5e0b8d0e2a | 230 | } |
demo71 | 3:9e5e0b8d0e2a | 231 | if(Boton2.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 232 | goto set_comp; |
demo71 | 3:9e5e0b8d0e2a | 233 | } |
demo71 | 3:9e5e0b8d0e2a | 234 | |
demo71 | 3:9e5e0b8d0e2a | 235 | |
demo71 | 3:9e5e0b8d0e2a | 236 | } |
demo71 | 3:9e5e0b8d0e2a | 237 | set_mm: |
demo71 | 3:9e5e0b8d0e2a | 238 | while(1){ |
demo71 | 3:9e5e0b8d0e2a | 239 | |
demo71 | 3:9e5e0b8d0e2a | 240 | mm=mm+wheel.getPulses(); |
demo71 | 3:9e5e0b8d0e2a | 241 | wheel.reset(); |
demo71 | 3:9e5e0b8d0e2a | 242 | ////////////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 243 | |
demo71 | 3:9e5e0b8d0e2a | 244 | if(mm>=59){ |
demo71 | 3:9e5e0b8d0e2a | 245 | mm=59; |
demo71 | 3:9e5e0b8d0e2a | 246 | } |
demo71 | 3:9e5e0b8d0e2a | 247 | else if (hh<=0){ |
demo71 | 3:9e5e0b8d0e2a | 248 | mm=0; |
demo71 | 3:9e5e0b8d0e2a | 249 | } |
demo71 | 3:9e5e0b8d0e2a | 250 | pc.printf(" Dia=%d Mes=%d Ano=%d Hora=%d >Min=%d Seg=%d\n ",dia,mes,ano,hh,mm,ss); |
demo71 | 3:9e5e0b8d0e2a | 251 | |
demo71 | 3:9e5e0b8d0e2a | 252 | |
demo71 | 3:9e5e0b8d0e2a | 253 | if(BotonENC.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 254 | goto set_ss; |
demo71 | 3:9e5e0b8d0e2a | 255 | } |
demo71 | 3:9e5e0b8d0e2a | 256 | if(Boton2.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 257 | goto set_comp; |
demo71 | 3:9e5e0b8d0e2a | 258 | } |
demo71 | 3:9e5e0b8d0e2a | 259 | |
demo71 | 3:9e5e0b8d0e2a | 260 | |
demo71 | 3:9e5e0b8d0e2a | 261 | } |
demo71 | 3:9e5e0b8d0e2a | 262 | |
demo71 | 3:9e5e0b8d0e2a | 263 | set_ss: |
demo71 | 3:9e5e0b8d0e2a | 264 | while(1){ |
demo71 | 3:9e5e0b8d0e2a | 265 | |
demo71 | 3:9e5e0b8d0e2a | 266 | ss=ss+wheel.getPulses(); |
demo71 | 3:9e5e0b8d0e2a | 267 | wheel.reset(); |
demo71 | 3:9e5e0b8d0e2a | 268 | ////////////////////////////////////////7 |
demo71 | 3:9e5e0b8d0e2a | 269 | |
demo71 | 3:9e5e0b8d0e2a | 270 | if(ss>=59){ |
demo71 | 3:9e5e0b8d0e2a | 271 | ss=59; |
demo71 | 3:9e5e0b8d0e2a | 272 | } |
demo71 | 3:9e5e0b8d0e2a | 273 | else if (ss<=0){ |
demo71 | 3:9e5e0b8d0e2a | 274 | ss=0; |
demo71 | 3:9e5e0b8d0e2a | 275 | } |
demo71 | 3:9e5e0b8d0e2a | 276 | pc.printf(" Dia=%d Mes=%d Ano=%d Hora=%d Min=%d >Seg=%d\n ",dia,mes,ano,hh,mm,ss); |
demo71 | 3:9e5e0b8d0e2a | 277 | |
demo71 | 3:9e5e0b8d0e2a | 278 | |
demo71 | 3:9e5e0b8d0e2a | 279 | if(BotonENC.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 280 | goto set_dia; |
demo71 | 3:9e5e0b8d0e2a | 281 | } |
demo71 | 3:9e5e0b8d0e2a | 282 | if(Boton2.falling()){ |
demo71 | 3:9e5e0b8d0e2a | 283 | goto set_comp; |
demo71 | 3:9e5e0b8d0e2a | 284 | } |
demo71 | 3:9e5e0b8d0e2a | 285 | |
demo71 | 3:9e5e0b8d0e2a | 286 | |
demo71 | 3:9e5e0b8d0e2a | 287 | } |
demo71 | 3:9e5e0b8d0e2a | 288 | |
demo71 | 3:9e5e0b8d0e2a | 289 | set_comp: |
demo71 | 3:9e5e0b8d0e2a | 290 | |
demo71 | 3:9e5e0b8d0e2a | 291 | pc.printf("***Datos ingresados para alarma****\n"); |
demo71 | 3:9e5e0b8d0e2a | 292 | pc.printf(" Dia=%d Mes=%d Ano=%d Hora=%d Min=%d Seg=%d\n ",dia,mes,ano,hh,mm,ss); |
demo71 | 3:9e5e0b8d0e2a | 293 | |
demo71 | 3:9e5e0b8d0e2a | 294 | while(1){ |
demo71 | 3:9e5e0b8d0e2a | 295 | rtc.getTime(tm); |
demo71 | 3:9e5e0b8d0e2a | 296 | pc.printf("The current time is : %02d:%02d:%02d\n", tm.hour, tm.min, tm.sec); |
demo71 | 3:9e5e0b8d0e2a | 297 | pc.printf("The current date is : %s, %02d/%02d/%04d\n", rtc.weekdayToString(tm.wday), tm.mon, tm.date, tm.year); |
demo71 | 3:9e5e0b8d0e2a | 298 | if(tm.hour>=hh && tm.min>=mm &&tm.sec>=ss && tm.mon>=mes && tm.date>=dia && tm.year>=ano){ |
demo71 | 3:9e5e0b8d0e2a | 299 | myled=0; |
demo71 | 3:9e5e0b8d0e2a | 300 | } |
demo71 | 3:9e5e0b8d0e2a | 301 | else { |
demo71 | 3:9e5e0b8d0e2a | 302 | myled=1; |
demo71 | 3:9e5e0b8d0e2a | 303 | } |
demo71 | 3:9e5e0b8d0e2a | 304 | wait(1); |
demo71 | 3:9e5e0b8d0e2a | 305 | } |
demo71 | 3:9e5e0b8d0e2a | 306 | //// |
demo71 | 3:9e5e0b8d0e2a | 307 | |
demo71 | 3:9e5e0b8d0e2a | 308 | } |
demo71 | 3:9e5e0b8d0e2a | 309 |