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.
Dependencies: HCSR04new SSH1106-alan
RTC/rtc.cpp
- Committer:
- alanchip
- Date:
- 2021-03-08
- Revision:
- 2:1baa0bd2fde0
- Child:
- 3:17acfeba3730
File content as of revision 2:1baa0bd2fde0:
#include "mbed.h"
#include "platform/mbed_thread.h"
#include "Thread_Handle.h"
#include "HCSR04.h"
#include "main.h"
#include "handleTasks.h"
struct tm st_tmp;
struct tm *p_tm;
time_t seconds;
void RTC_INIT()
{
st_tmp.tm_year = 2020-1900;
st_tmp.tm_mon = 9;
st_tmp.tm_mday = 27;
st_tmp.tm_hour = 1;
st_tmp.tm_min = 53;
st_tmp.tm_sec = 30;
seconds = mktime(&st_tmp);
set_time(seconds);
}
//display time printf
void RTC_display ()
{
seconds = time(NULL);
p_tm = localtime(&seconds);
//Display format year-month-day hour:min:sec
printf("%04d-%02d-%04d %02d:%02d:%02d \n\n", p_tm->tm_year + 1900,p_tm->tm_mon,p_tm->tm_mday, p_tm->tm_hour, p_tm->tm_min, p_tm->tm_sec);
}