newest

Dependencies:   BME280 BMP280 TextLCD mbed

Fork of CW_watchdog_08012018_newest by Calvin Kalintra

Committer:
ckalintra
Date:
Tue Jan 09 15:45:56 2018 +0000
Revision:
5:8aa72ee456fc
Parent:
1:dc21a6fce3af
s

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ckalintra 0:7023c3f98f36 1 #include "mbed.h"
ckalintra 0:7023c3f98f36 2 DigitalIn sw1(PE_12);
ckalintra 0:7023c3f98f36 3 DigitalIn sw2(PE_14);
ckalintra 0:7023c3f98f36 4 int d = 0,dd = 0,m = 0,mm = 0,y = 0,yy = 0,yyy = 0,yyyy = 0, pointer = 0, h = 0, hh = 0, mi = 0, mmi = 0, s = 0, ss = 0;
ckalintra 0:7023c3f98f36 5 TextLCD lcd(D9,D8,D7,D6,D4,D2);
ckalintra 0:7023c3f98f36 6
ckalintra 0:7023c3f98f36 7
ckalintra 0:7023c3f98f36 8
ckalintra 0:7023c3f98f36 9
ckalintra 0:7023c3f98f36 10 void display_date_time()
ckalintra 0:7023c3f98f36 11 {
ckalintra 0:7023c3f98f36 12 lcd.locate(0,0);
ckalintra 0:7023c3f98f36 13 lcd.printf("%i", d);
ckalintra 0:7023c3f98f36 14 lcd.locate(1,0);
ckalintra 0:7023c3f98f36 15 lcd.printf("%i", dd);
ckalintra 0:7023c3f98f36 16 lcd.locate(3,0);
ckalintra 0:7023c3f98f36 17 lcd.printf("%i", m);
ckalintra 0:7023c3f98f36 18 lcd.locate(4,0);
ckalintra 0:7023c3f98f36 19 lcd.printf("%i", mm);
ckalintra 0:7023c3f98f36 20 lcd.locate(6,0);
ckalintra 0:7023c3f98f36 21 lcd.printf("%i", y);
ckalintra 0:7023c3f98f36 22 lcd.locate(7,0);
ckalintra 0:7023c3f98f36 23 lcd.printf("%i", yy);
ckalintra 0:7023c3f98f36 24 lcd.locate(8,0);
ckalintra 0:7023c3f98f36 25 lcd.printf("%i", yyy);
ckalintra 0:7023c3f98f36 26 lcd.locate(9,0);
ckalintra 0:7023c3f98f36 27 lcd.printf("%i", yyyy);
ckalintra 0:7023c3f98f36 28 lcd.locate(0,1);
ckalintra 0:7023c3f98f36 29 lcd.printf("%i", h);
ckalintra 0:7023c3f98f36 30 lcd.locate(1,1);
ckalintra 0:7023c3f98f36 31 lcd.printf("%i", hh);
ckalintra 0:7023c3f98f36 32 lcd.locate(3,1);
ckalintra 0:7023c3f98f36 33 lcd.printf("%i", mi);
ckalintra 0:7023c3f98f36 34 lcd.locate(4,1);
ckalintra 0:7023c3f98f36 35 lcd.printf("%i", mmi);
ckalintra 0:7023c3f98f36 36 lcd.locate(6,1);
ckalintra 0:7023c3f98f36 37 lcd.printf("%i", s);
ckalintra 0:7023c3f98f36 38 lcd.locate(7,1);
ckalintra 0:7023c3f98f36 39 lcd.printf("%i", ss);
ckalintra 0:7023c3f98f36 40 }
ckalintra 0:7023c3f98f36 41
ckalintra 0:7023c3f98f36 42 void display_time()
ckalintra 0:7023c3f98f36 43 {
ckalintra 0:7023c3f98f36 44 lcd.locate(0,1);
ckalintra 0:7023c3f98f36 45 lcd.printf("%i", h);
ckalintra 0:7023c3f98f36 46 lcd.locate(1,1);
ckalintra 0:7023c3f98f36 47 lcd.printf("%i", hh);
ckalintra 0:7023c3f98f36 48 lcd.locate(2,1);
ckalintra 0:7023c3f98f36 49 lcd.printf(":");
ckalintra 0:7023c3f98f36 50 lcd.locate(3,1);
ckalintra 0:7023c3f98f36 51 lcd.printf("%i", mi);
ckalintra 0:7023c3f98f36 52 lcd.locate(4,1);
ckalintra 0:7023c3f98f36 53 lcd.printf("%i", mmi);
ckalintra 0:7023c3f98f36 54 lcd.locate(5,1);
ckalintra 0:7023c3f98f36 55 lcd.printf(":");
ckalintra 0:7023c3f98f36 56 lcd.locate(6,1);
ckalintra 0:7023c3f98f36 57 lcd.printf("%i", s);
ckalintra 0:7023c3f98f36 58 lcd.locate(7,1);
ckalintra 0:7023c3f98f36 59 lcd.printf("%i", ss);
ckalintra 0:7023c3f98f36 60 }
ckalintra 0:7023c3f98f36 61
ckalintra 0:7023c3f98f36 62 void display_dates()
ckalintra 0:7023c3f98f36 63 {
ckalintra 0:7023c3f98f36 64 lcd.locate(0,0);
ckalintra 0:7023c3f98f36 65 lcd.printf("%i", d);
ckalintra 0:7023c3f98f36 66 lcd.locate(1,0);
ckalintra 0:7023c3f98f36 67 lcd.printf("%i", dd);
ckalintra 0:7023c3f98f36 68 lcd.locate(2,0);
ckalintra 0:7023c3f98f36 69 lcd.printf(":");
ckalintra 0:7023c3f98f36 70 lcd.locate(3,0);
ckalintra 0:7023c3f98f36 71 lcd.printf("%i", m);
ckalintra 0:7023c3f98f36 72 lcd.locate(4,0);
ckalintra 0:7023c3f98f36 73 lcd.printf("%i", mm);
ckalintra 0:7023c3f98f36 74 lcd.locate(5,0);
ckalintra 0:7023c3f98f36 75 lcd.printf(":");
ckalintra 0:7023c3f98f36 76 lcd.locate(6,0);
ckalintra 0:7023c3f98f36 77 lcd.printf("%i", y);
ckalintra 0:7023c3f98f36 78 lcd.locate(7,0);
ckalintra 0:7023c3f98f36 79 lcd.printf("%i", yy);
ckalintra 0:7023c3f98f36 80 lcd.locate(8,0);
ckalintra 0:7023c3f98f36 81 lcd.printf("%i", yyy);
ckalintra 0:7023c3f98f36 82 lcd.locate(9,0);
ckalintra 0:7023c3f98f36 83 lcd.printf("%i", yyyy);
ckalintra 0:7023c3f98f36 84 }
ckalintra 0:7023c3f98f36 85
ckalintra 0:7023c3f98f36 86
ckalintra 0:7023c3f98f36 87 void update_date_and_time()
ckalintra 0:7023c3f98f36 88 {
ckalintra 0:7023c3f98f36 89 if (pointer == 0)
ckalintra 0:7023c3f98f36 90 {
ckalintra 0:7023c3f98f36 91 lcd.locate(0,0);
ckalintra 0:7023c3f98f36 92 lcd.printf("%i", d);
ckalintra 0:7023c3f98f36 93 }
ckalintra 0:7023c3f98f36 94
ckalintra 0:7023c3f98f36 95 if (pointer == 1)
ckalintra 0:7023c3f98f36 96 {
ckalintra 0:7023c3f98f36 97 lcd.locate(1,0);
ckalintra 0:7023c3f98f36 98 lcd.printf("%i", dd);
ckalintra 0:7023c3f98f36 99 }
ckalintra 0:7023c3f98f36 100
ckalintra 0:7023c3f98f36 101 if (pointer == 2)
ckalintra 0:7023c3f98f36 102 {
ckalintra 0:7023c3f98f36 103 lcd.locate(3,0);
ckalintra 0:7023c3f98f36 104 lcd.printf("%i", m);
ckalintra 0:7023c3f98f36 105 }
ckalintra 0:7023c3f98f36 106
ckalintra 0:7023c3f98f36 107 if (pointer == 3)
ckalintra 0:7023c3f98f36 108 {
ckalintra 0:7023c3f98f36 109 lcd.locate(4,0);
ckalintra 0:7023c3f98f36 110 lcd.printf("%i", mm);
ckalintra 0:7023c3f98f36 111 }
ckalintra 0:7023c3f98f36 112
ckalintra 0:7023c3f98f36 113 if (pointer == 4)
ckalintra 0:7023c3f98f36 114 {
ckalintra 0:7023c3f98f36 115 lcd.locate(6,0);
ckalintra 0:7023c3f98f36 116 lcd.printf("%i", y);
ckalintra 0:7023c3f98f36 117 }
ckalintra 0:7023c3f98f36 118
ckalintra 0:7023c3f98f36 119 if (pointer == 5)
ckalintra 0:7023c3f98f36 120 {
ckalintra 0:7023c3f98f36 121 lcd.locate(7,0);
ckalintra 0:7023c3f98f36 122 lcd.printf("%i", yy);
ckalintra 0:7023c3f98f36 123 }
ckalintra 0:7023c3f98f36 124 if (pointer == 6)
ckalintra 0:7023c3f98f36 125 {
ckalintra 0:7023c3f98f36 126 lcd.locate(8,0);
ckalintra 0:7023c3f98f36 127 lcd.printf("%i", yyy);
ckalintra 0:7023c3f98f36 128 }
ckalintra 0:7023c3f98f36 129
ckalintra 0:7023c3f98f36 130 if (pointer == 7)
ckalintra 0:7023c3f98f36 131 {
ckalintra 0:7023c3f98f36 132 lcd.locate(9,0);
ckalintra 0:7023c3f98f36 133 lcd.printf("%i", yyyy);
ckalintra 0:7023c3f98f36 134 }
ckalintra 0:7023c3f98f36 135 if (pointer == 8)
ckalintra 0:7023c3f98f36 136 {
ckalintra 0:7023c3f98f36 137 lcd.locate(0,1);
ckalintra 0:7023c3f98f36 138 lcd.printf("%i", h);
ckalintra 0:7023c3f98f36 139 }
ckalintra 0:7023c3f98f36 140 if (pointer == 9)
ckalintra 0:7023c3f98f36 141 {
ckalintra 0:7023c3f98f36 142 lcd.locate(1,1);
ckalintra 0:7023c3f98f36 143 lcd.printf("%i", hh);
ckalintra 0:7023c3f98f36 144 }
ckalintra 0:7023c3f98f36 145
ckalintra 0:7023c3f98f36 146 if (pointer == 10)
ckalintra 0:7023c3f98f36 147 {
ckalintra 0:7023c3f98f36 148 lcd.locate(3,1);
ckalintra 0:7023c3f98f36 149 lcd.printf("%i", mi);
ckalintra 0:7023c3f98f36 150 }
ckalintra 0:7023c3f98f36 151 if (pointer == 11)
ckalintra 0:7023c3f98f36 152 {
ckalintra 0:7023c3f98f36 153 lcd.locate(4,1);
ckalintra 0:7023c3f98f36 154 lcd.printf("%i", mmi);
ckalintra 0:7023c3f98f36 155 }
ckalintra 0:7023c3f98f36 156 if (pointer == 12)
ckalintra 0:7023c3f98f36 157 {
ckalintra 0:7023c3f98f36 158 lcd.locate(6,1);
ckalintra 0:7023c3f98f36 159 lcd.printf("%i", s);
ckalintra 0:7023c3f98f36 160 }
ckalintra 0:7023c3f98f36 161
ckalintra 0:7023c3f98f36 162 if (pointer == 13)
ckalintra 0:7023c3f98f36 163 {
ckalintra 0:7023c3f98f36 164 lcd.locate(7,1);
ckalintra 0:7023c3f98f36 165 lcd.printf("%i", ss);
ckalintra 0:7023c3f98f36 166 }
ckalintra 0:7023c3f98f36 167 }
ckalintra 0:7023c3f98f36 168
ckalintra 0:7023c3f98f36 169 void select_date()
ckalintra 0:7023c3f98f36 170 {
ckalintra 0:7023c3f98f36 171 if (sw2 == 1)
ckalintra 0:7023c3f98f36 172 {
ckalintra 1:dc21a6fce3af 173 wait (0.2);
ckalintra 0:7023c3f98f36 174 pointer++;
ckalintra 0:7023c3f98f36 175 }
ckalintra 0:7023c3f98f36 176 else if(pointer != 14)
ckalintra 0:7023c3f98f36 177 {
ckalintra 0:7023c3f98f36 178 switch (pointer)
ckalintra 0:7023c3f98f36 179 {
ckalintra 0:7023c3f98f36 180 case 0:
ckalintra 0:7023c3f98f36 181 if (sw1 == 1)
ckalintra 0:7023c3f98f36 182 {
ckalintra 1:dc21a6fce3af 183 wait (0.2);
ckalintra 0:7023c3f98f36 184 d++;
ckalintra 0:7023c3f98f36 185 if (d == 4)
ckalintra 0:7023c3f98f36 186 {
ckalintra 0:7023c3f98f36 187 d = 0;
ckalintra 0:7023c3f98f36 188 }
ckalintra 0:7023c3f98f36 189 }
ckalintra 0:7023c3f98f36 190 case 1:
ckalintra 0:7023c3f98f36 191 if (sw1 == 1)
ckalintra 0:7023c3f98f36 192 {
ckalintra 1:dc21a6fce3af 193 wait (0.2);
ckalintra 0:7023c3f98f36 194 dd++;
ckalintra 0:7023c3f98f36 195 if (dd == 10)
ckalintra 0:7023c3f98f36 196 {
ckalintra 0:7023c3f98f36 197 dd = 0;
ckalintra 0:7023c3f98f36 198 }
ckalintra 0:7023c3f98f36 199 }
ckalintra 0:7023c3f98f36 200 case 2:
ckalintra 0:7023c3f98f36 201 if (sw1 == 1)
ckalintra 0:7023c3f98f36 202 {
ckalintra 1:dc21a6fce3af 203 wait (0.2);
ckalintra 0:7023c3f98f36 204 m++;
ckalintra 0:7023c3f98f36 205 if (m == 2)
ckalintra 0:7023c3f98f36 206 {
ckalintra 0:7023c3f98f36 207 m = 0;
ckalintra 0:7023c3f98f36 208 }
ckalintra 0:7023c3f98f36 209 }
ckalintra 0:7023c3f98f36 210 case 3:
ckalintra 0:7023c3f98f36 211 if (sw1 == 1)
ckalintra 0:7023c3f98f36 212 {
ckalintra 1:dc21a6fce3af 213 wait (0.2);
ckalintra 0:7023c3f98f36 214 mm++;
ckalintra 0:7023c3f98f36 215 if (mm == 10)
ckalintra 0:7023c3f98f36 216 {
ckalintra 0:7023c3f98f36 217 mm = 0;
ckalintra 0:7023c3f98f36 218 }
ckalintra 0:7023c3f98f36 219 }
ckalintra 0:7023c3f98f36 220 case 4:
ckalintra 0:7023c3f98f36 221 if (sw1 == 1)
ckalintra 0:7023c3f98f36 222 {
ckalintra 1:dc21a6fce3af 223 wait (0.2);
ckalintra 0:7023c3f98f36 224 y++;
ckalintra 0:7023c3f98f36 225 if (y == 3)
ckalintra 0:7023c3f98f36 226 {
ckalintra 0:7023c3f98f36 227 y = 0;
ckalintra 0:7023c3f98f36 228 }
ckalintra 0:7023c3f98f36 229 }
ckalintra 0:7023c3f98f36 230 case 5:
ckalintra 0:7023c3f98f36 231 if (sw1 == 1)
ckalintra 0:7023c3f98f36 232 {
ckalintra 1:dc21a6fce3af 233 wait (0.2);
ckalintra 0:7023c3f98f36 234 yy++;
ckalintra 0:7023c3f98f36 235 if (yy == 10)
ckalintra 0:7023c3f98f36 236 {
ckalintra 0:7023c3f98f36 237 yy = 0;
ckalintra 0:7023c3f98f36 238 }
ckalintra 0:7023c3f98f36 239 }
ckalintra 0:7023c3f98f36 240 case 6:
ckalintra 0:7023c3f98f36 241 if (sw1 == 1)
ckalintra 0:7023c3f98f36 242 {
ckalintra 1:dc21a6fce3af 243 wait (0.2);
ckalintra 0:7023c3f98f36 244 yyy++;
ckalintra 0:7023c3f98f36 245 if (yyy == 10)
ckalintra 0:7023c3f98f36 246 {
ckalintra 0:7023c3f98f36 247 yyy = 0;
ckalintra 0:7023c3f98f36 248 }
ckalintra 0:7023c3f98f36 249 }
ckalintra 0:7023c3f98f36 250 case 7:
ckalintra 0:7023c3f98f36 251 if (sw1 == 1)
ckalintra 0:7023c3f98f36 252 {
ckalintra 1:dc21a6fce3af 253 wait (0.2);
ckalintra 0:7023c3f98f36 254 yyyy++;
ckalintra 0:7023c3f98f36 255 if (yyyy == 10)
ckalintra 0:7023c3f98f36 256 {
ckalintra 0:7023c3f98f36 257 yyyy = 0;
ckalintra 0:7023c3f98f36 258 }
ckalintra 0:7023c3f98f36 259 }
ckalintra 0:7023c3f98f36 260 case 8:
ckalintra 0:7023c3f98f36 261 if (sw1 == 1)
ckalintra 0:7023c3f98f36 262 {
ckalintra 1:dc21a6fce3af 263 wait (0.2);
ckalintra 0:7023c3f98f36 264 h++;
ckalintra 0:7023c3f98f36 265 if (h== 3)
ckalintra 0:7023c3f98f36 266 {
ckalintra 0:7023c3f98f36 267 h = 0;
ckalintra 0:7023c3f98f36 268 }
ckalintra 0:7023c3f98f36 269 }
ckalintra 0:7023c3f98f36 270 case 9:
ckalintra 0:7023c3f98f36 271 if (sw1 == 1)
ckalintra 0:7023c3f98f36 272 {
ckalintra 1:dc21a6fce3af 273 wait (0.2);
ckalintra 0:7023c3f98f36 274 hh++;
ckalintra 0:7023c3f98f36 275 if (hh == 10)
ckalintra 0:7023c3f98f36 276 {
ckalintra 0:7023c3f98f36 277 hh = 0;
ckalintra 0:7023c3f98f36 278 }
ckalintra 0:7023c3f98f36 279 }
ckalintra 0:7023c3f98f36 280 case 10:
ckalintra 0:7023c3f98f36 281 if (sw1 == 1)
ckalintra 0:7023c3f98f36 282 {
ckalintra 1:dc21a6fce3af 283 wait (0.2);
ckalintra 0:7023c3f98f36 284 mi++;
ckalintra 0:7023c3f98f36 285 if (mi == 6)
ckalintra 0:7023c3f98f36 286 {
ckalintra 0:7023c3f98f36 287 mi = 0;
ckalintra 0:7023c3f98f36 288 }
ckalintra 0:7023c3f98f36 289 }
ckalintra 0:7023c3f98f36 290 case 11:
ckalintra 0:7023c3f98f36 291 if (sw1 == 1)
ckalintra 0:7023c3f98f36 292 {
ckalintra 1:dc21a6fce3af 293 wait (0.2);
ckalintra 0:7023c3f98f36 294 mmi++;
ckalintra 0:7023c3f98f36 295 if (mmi == 10)
ckalintra 0:7023c3f98f36 296 {
ckalintra 0:7023c3f98f36 297 mmi = 0;
ckalintra 0:7023c3f98f36 298 }
ckalintra 0:7023c3f98f36 299 }
ckalintra 0:7023c3f98f36 300 case 12:
ckalintra 0:7023c3f98f36 301 if (sw1 == 1)
ckalintra 0:7023c3f98f36 302 {
ckalintra 1:dc21a6fce3af 303 wait (0.2);
ckalintra 0:7023c3f98f36 304 s++;
ckalintra 0:7023c3f98f36 305 if (s == 6)
ckalintra 0:7023c3f98f36 306 {
ckalintra 0:7023c3f98f36 307 s = 0;
ckalintra 0:7023c3f98f36 308 }
ckalintra 0:7023c3f98f36 309 }
ckalintra 0:7023c3f98f36 310 case 13:
ckalintra 0:7023c3f98f36 311 if (sw1 == 1)
ckalintra 0:7023c3f98f36 312 {
ckalintra 1:dc21a6fce3af 313 wait (0.2);
ckalintra 0:7023c3f98f36 314 ss++;
ckalintra 0:7023c3f98f36 315 if (ss == 10)
ckalintra 0:7023c3f98f36 316 {
ckalintra 0:7023c3f98f36 317 ss = 0;
ckalintra 0:7023c3f98f36 318 }
ckalintra 0:7023c3f98f36 319 }
ckalintra 0:7023c3f98f36 320
ckalintra 0:7023c3f98f36 321
ckalintra 0:7023c3f98f36 322
ckalintra 0:7023c3f98f36 323 }
ckalintra 0:7023c3f98f36 324 }
ckalintra 0:7023c3f98f36 325 update_date_and_time();
ckalintra 0:7023c3f98f36 326 }
ckalintra 0:7023c3f98f36 327
ckalintra 0:7023c3f98f36 328
ckalintra 0:7023c3f98f36 329
ckalintra 0:7023c3f98f36 330
ckalintra 0:7023c3f98f36 331
ckalintra 0:7023c3f98f36 332
ckalintra 0:7023c3f98f36 333
ckalintra 0:7023c3f98f36 334