![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
cbcx
Dependencies: DmTftLibrary mbed
Fork of LCD_Proj by
rtc.h@1:81d0d835991d, 2015-12-21 (annotated)
- Committer:
- Nikolas
- Date:
- Mon Dec 21 12:37:40 2015 +0000
- Revision:
- 1:81d0d835991d
xcbcxbc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nikolas | 1:81d0d835991d | 1 | #include "mbed.h" |
Nikolas | 1:81d0d835991d | 2 | Serial pc (USBTX,USBRX); |
Nikolas | 1:81d0d835991d | 3 | C12832_LCD lcd; |
Nikolas | 1:81d0d835991d | 4 | |
Nikolas | 1:81d0d835991d | 5 | int main () { |
Nikolas | 1:81d0d835991d | 6 | char timeString[20]; |
Nikolas | 1:81d0d835991d | 7 | pc.baud(115200); |
Nikolas | 1:81d0d835991d | 8 | lcd.cls(); |
Nikolas | 1:81d0d835991d | 9 | lcd.set_contrast(30); // 0-63 |
Nikolas | 1:81d0d835991d | 10 | |
Nikolas | 1:81d0d835991d | 11 | // setup time structure |
Nikolas | 1:81d0d835991d | 12 | struct tm t; |
Nikolas | 1:81d0d835991d | 13 | t.tm_sec = 00; // 0-59 |
Nikolas | 1:81d0d835991d | 14 | t.tm_min = 21; // 0-59 |
Nikolas | 1:81d0d835991d | 15 | t.tm_hour = 16; // 0-23 |
Nikolas | 1:81d0d835991d | 16 | t.tm_mday = 21; // 1-31 |
Nikolas | 1:81d0d835991d | 17 | t.tm_mon = 12; // 0-11 |
Nikolas | 1:81d0d835991d | 18 | t.tm_year = 115; // year since 1900 |
Nikolas | 1:81d0d835991d | 19 | |
Nikolas | 1:81d0d835991d | 20 | // convert to timestamp |
Nikolas | 1:81d0d835991d | 21 | time_t secondsSince1970 = mktime(&t); |
Nikolas | 1:81d0d835991d | 22 | pc.printf("Seconds since January 1, 1970: %d\r\n", secondsSince1970); |
Nikolas | 1:81d0d835991d | 23 | |
Nikolas | 1:81d0d835991d | 24 | // Set time and start RTC |
Nikolas | 1:81d0d835991d | 25 | set_time(secondsSince1970); |
Nikolas | 1:81d0d835991d | 26 | |
Nikolas | 1:81d0d835991d | 27 | while(1) { |
Nikolas | 1:81d0d835991d | 28 | secondsSince1970 = time(NULL); |
Nikolas | 1:81d0d835991d | 29 | strftime(timeString, 20, "%H:%M:%S\r\n", localtime(&secondsSince1970)); |
Nikolas | 1:81d0d835991d | 30 | pc.printf("aktuelle Zeit = %s", timeString); |
Nikolas | 1:81d0d835991d | 31 | lcd.locate(0,0); |
Nikolas | 1:81d0d835991d | 32 | lcd.printf("aktuelle Zeit = %s", timeString); |
Nikolas | 1:81d0d835991d | 33 | |
Nikolas | 1:81d0d835991d | 34 | wait(1.0); |
Nikolas | 1:81d0d835991d | 35 | } |
Nikolas | 1:81d0d835991d | 36 | } |
Nikolas | 1:81d0d835991d | 37 |