Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of clock by
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 TextLCD lcd(p24, p26, p27, p28, p29, p30); 00005 00006 int main() { 00007 // setup time structure for Wed, 11 April 2013 5:00:00 00008 struct tm t; 00009 t.tm_sec = 00; // 0-59 00010 t.tm_min = 00; // 0-59 00011 t.tm_hour = 5; // 0-23 00012 t.tm_mday = 11; // 1-31 00013 t.tm_mon = 3; // 0-11 00014 t.tm_year = 113; // year since 1900 00015 00016 // convert to timestamp 00017 time_t seconds = mktime(&t); 00018 00019 // Set RTC time today 00020 set_time(mktime(&t)); 00021 00022 while(1) { 00023 00024 time_t seconds = time(NULL); 00025 00026 lcd.locate(0,0); 00027 char day[16]; 00028 strftime(day, 16, "%Y/%m/%d %a\n", localtime(&seconds)); 00029 lcd.printf("%s", day); 00030 00031 char time[16]; 00032 strftime(time, 16, "%H:%M:%S\n", localtime(&seconds)); 00033 lcd.locate(0,1); 00034 lcd.printf("%s", time); 00035 00036 00037 wait(1.0); 00038 } 00039 00040 00041 00042 00043 }
Generated on Wed Jul 13 2022 20:29:33 by
1.7.2
