![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
newest
Dependencies: BME280 BMP280 TextLCD mbed
Fork of CW_watchdog_08012018 by
Diff: date.h
- Revision:
- 0:7023c3f98f36
- Child:
- 1:dc21a6fce3af
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/date.h Sat Jan 06 17:28:05 2018 +0000 @@ -0,0 +1,334 @@ +#include "mbed.h" +DigitalIn sw1(PE_12); +DigitalIn sw2(PE_14); +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; +TextLCD lcd(D9,D8,D7,D6,D4,D2); + + + + +void display_date_time() +{ + lcd.locate(0,0); + lcd.printf("%i", d); + lcd.locate(1,0); + lcd.printf("%i", dd); + lcd.locate(3,0); + lcd.printf("%i", m); + lcd.locate(4,0); + lcd.printf("%i", mm); + lcd.locate(6,0); + lcd.printf("%i", y); + lcd.locate(7,0); + lcd.printf("%i", yy); + lcd.locate(8,0); + lcd.printf("%i", yyy); + lcd.locate(9,0); + lcd.printf("%i", yyyy); + lcd.locate(0,1); + lcd.printf("%i", h); + lcd.locate(1,1); + lcd.printf("%i", hh); + lcd.locate(3,1); + lcd.printf("%i", mi); + lcd.locate(4,1); + lcd.printf("%i", mmi); + lcd.locate(6,1); + lcd.printf("%i", s); + lcd.locate(7,1); + lcd.printf("%i", ss); +} + +void display_time() +{ + lcd.locate(0,1); + lcd.printf("%i", h); + lcd.locate(1,1); + lcd.printf("%i", hh); + lcd.locate(2,1); + lcd.printf(":"); + lcd.locate(3,1); + lcd.printf("%i", mi); + lcd.locate(4,1); + lcd.printf("%i", mmi); + lcd.locate(5,1); + lcd.printf(":"); + lcd.locate(6,1); + lcd.printf("%i", s); + lcd.locate(7,1); + lcd.printf("%i", ss); +} + +void display_dates() +{ + lcd.locate(0,0); + lcd.printf("%i", d); + lcd.locate(1,0); + lcd.printf("%i", dd); + lcd.locate(2,0); + lcd.printf(":"); + lcd.locate(3,0); + lcd.printf("%i", m); + lcd.locate(4,0); + lcd.printf("%i", mm); + lcd.locate(5,0); + lcd.printf(":"); + lcd.locate(6,0); + lcd.printf("%i", y); + lcd.locate(7,0); + lcd.printf("%i", yy); + lcd.locate(8,0); + lcd.printf("%i", yyy); + lcd.locate(9,0); + lcd.printf("%i", yyyy); +} + + +void update_date_and_time() +{ + if (pointer == 0) + { + lcd.locate(0,0); + lcd.printf("%i", d); + } + + if (pointer == 1) + { + lcd.locate(1,0); + lcd.printf("%i", dd); + } + + if (pointer == 2) + { + lcd.locate(3,0); + lcd.printf("%i", m); + } + + if (pointer == 3) + { + lcd.locate(4,0); + lcd.printf("%i", mm); + } + + if (pointer == 4) + { + lcd.locate(6,0); + lcd.printf("%i", y); + } + + if (pointer == 5) + { + lcd.locate(7,0); + lcd.printf("%i", yy); + } + if (pointer == 6) + { + lcd.locate(8,0); + lcd.printf("%i", yyy); + } + + if (pointer == 7) + { + lcd.locate(9,0); + lcd.printf("%i", yyyy); + } + if (pointer == 8) + { + lcd.locate(0,1); + lcd.printf("%i", h); + } + if (pointer == 9) + { + lcd.locate(1,1); + lcd.printf("%i", hh); + } + + if (pointer == 10) + { + lcd.locate(3,1); + lcd.printf("%i", mi); + } + if (pointer == 11) + { + lcd.locate(4,1); + lcd.printf("%i", mmi); + } + if (pointer == 12) + { + lcd.locate(6,1); + lcd.printf("%i", s); + } + + if (pointer == 13) + { + lcd.locate(7,1); + lcd.printf("%i", ss); + } +} + +void select_date() +{ + if (sw2 == 1) + { + wait (1); + pointer++; + } + else if(pointer != 14) + { + switch (pointer) + { + case 0: + if (sw1 == 1) + { + wait (1); + d++; + if (d == 4) + { + d = 0; + } + } + case 1: + if (sw1 == 1) + { + wait (1); + dd++; + if (dd == 10) + { + dd = 0; + } + } + case 2: + if (sw1 == 1) + { + wait (1); + m++; + if (m == 2) + { + m = 0; + } + } + case 3: + if (sw1 == 1) + { + wait (1); + mm++; + if (mm == 10) + { + mm = 0; + } + } + case 4: + if (sw1 == 1) + { + wait (1); + y++; + if (y == 3) + { + y = 0; + } + } + case 5: + if (sw1 == 1) + { + wait (1); + yy++; + if (yy == 10) + { + yy = 0; + } + } + case 6: + if (sw1 == 1) + { + wait (1); + yyy++; + if (yyy == 10) + { + yyy = 0; + } + } + case 7: + if (sw1 == 1) + { + wait (1); + yyyy++; + if (yyyy == 10) + { + yyyy = 0; + } + } + case 8: + if (sw1 == 1) + { + wait (1); + h++; + if (h== 3) + { + h = 0; + } + } + case 9: + if (sw1 == 1) + { + wait (1); + hh++; + if (hh == 10) + { + hh = 0; + } + } + case 10: + if (sw1 == 1) + { + wait (1); + mi++; + if (mi == 6) + { + mi = 0; + } + } + case 11: + if (sw1 == 1) + { + wait (1); + mmi++; + if (mmi == 10) + { + mmi = 0; + } + } + case 12: + if (sw1 == 1) + { + wait (1); + s++; + if (s == 6) + { + s = 0; + } + } + case 13: + if (sw1 == 1) + { + wait (1); + ss++; + if (ss == 10) + { + ss = 0; + } + } + + + + } + } +update_date_and_time(); +} + + + + + + + + \ No newline at end of file