![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Programski kod sata/brojača. Izveden pomoću 4 tipkala i LCD zaslonom rezolucije 16x2 točaka.
Dependencies: mbed Bljeskalica TextLCD
Prikaz trenutnog vremena i datuma na LCD zaslonu rezolucije 16x2 točaka. U gornjem redu prikazuje se datum u formatu: dan/mjesec/godina, a u donjem redu vrijeme u formatu: sat/minuta/sekunda. Podešenje vremena i datuma je pomoću tipkala i to u inkrementima po 1 (sekunda, minuta, sat, dan, mjesec, godina).
main.h@0:1c9b141ec08b, 2020-06-11 (annotated)
- Committer:
- dariojankovic
- Date:
- Thu Jun 11 22:28:08 2020 +0000
- Revision:
- 0:1c9b141ec08b
Proba
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dariojankovic | 0:1c9b141ec08b | 1 | #include "mbed.h" |
dariojankovic | 0:1c9b141ec08b | 2 | #include "TextLCD.h" |
dariojankovic | 0:1c9b141ec08b | 3 | #include "Flasher.h" |
dariojankovic | 0:1c9b141ec08b | 4 | #include "tipkala.h" |
dariojankovic | 0:1c9b141ec08b | 5 | |
dariojankovic | 0:1c9b141ec08b | 6 | TextLCD LCD (p19, p20, p21, p22, p23, p24); //RS,E,D0,D1,D2,D3 |
dariojankovic | 0:1c9b141ec08b | 7 | |
dariojankovic | 0:1c9b141ec08b | 8 | Flasher led(LED1); |
dariojankovic | 0:1c9b141ec08b | 9 | |
dariojankovic | 0:1c9b141ec08b | 10 | int MENU = 0; |
dariojankovic | 0:1c9b141ec08b | 11 | |
dariojankovic | 0:1c9b141ec08b | 12 | void ZASLON(); |
dariojankovic | 0:1c9b141ec08b | 13 | |
dariojankovic | 0:1c9b141ec08b | 14 | void vrijeme() { |
dariojankovic | 0:1c9b141ec08b | 15 | set_time(1577836800+offset); } |
dariojankovic | 0:1c9b141ec08b | 16 | |
dariojankovic | 0:1c9b141ec08b | 17 | void ZASLON() { |
dariojankovic | 0:1c9b141ec08b | 18 | time_t seconds = time(NULL); |
dariojankovic | 0:1c9b141ec08b | 19 | |
dariojankovic | 0:1c9b141ec08b | 20 | if (MENU==0) { |
dariojankovic | 0:1c9b141ec08b | 21 | LCD.cls(); |
dariojankovic | 0:1c9b141ec08b | 22 | LCD.locate(2,0); |
dariojankovic | 0:1c9b141ec08b | 23 | char day[16]; |
dariojankovic | 0:1c9b141ec08b | 24 | |
dariojankovic | 0:1c9b141ec08b | 25 | strftime(day, 16, "%d/%m/%y %a\n", localtime(&seconds)); |
dariojankovic | 0:1c9b141ec08b | 26 | LCD.printf("%s", day); |
dariojankovic | 0:1c9b141ec08b | 27 | |
dariojankovic | 0:1c9b141ec08b | 28 | char time[16]; |
dariojankovic | 0:1c9b141ec08b | 29 | strftime(time, 16, "%H:%M:%S\n", localtime(&seconds)); |
dariojankovic | 0:1c9b141ec08b | 30 | LCD.locate(4,1); |
dariojankovic | 0:1c9b141ec08b | 31 | LCD.printf("%s", time);} |
dariojankovic | 0:1c9b141ec08b | 32 | } |
dariojankovic | 0:1c9b141ec08b | 33 |