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.
Diff: main.cpp
- Revision:
- 3:a9453e8c6641
- Parent:
- 2:9b1e5efd9a09
- Child:
- 4:e2b18050c4d5
--- a/main.cpp Wed Nov 26 20:32:16 2014 +0000
+++ b/main.cpp Fri Nov 28 02:46:57 2014 +0000
@@ -44,6 +44,7 @@
#include "ard2pmod.h"
+#define ESC 0x1B
void get_user_input(char* message, uint8_t min, uint8_t max, uint8_t* member);
@@ -76,6 +77,8 @@
ds3231_time_t rtc_time;
ds3231_calendar_t rtc_calendar;
+ time_t epoch_time;
+
ard2pmod.set_cntl_stat_reg(rtc_control_status);
//get day from user
@@ -89,7 +92,7 @@
//get month from user
get_user_input("\nPlease enter the month, 1 for January (1-12): ", 1,
12, &rtc_calendar.month);
-
+
//get year from user
get_user_input("\nPlease enter the year (0-99): ",0, 99,
&rtc_calendar.year);
@@ -118,48 +121,34 @@
get_user_input("\nPlease enter the minute (0-59): ", 0, 59,
&rtc_time.minutes);
-
//Get seconds from user
get_user_input("\nPlease enter the second (0-59): ", 0, 59,
&rtc_time.seconds);
-
-
-
+
//Set the time
ard2pmod.set_time(rtc_time);
//Set the calendar
ard2pmod.set_calendar(rtc_calendar);
+ char buffer[32];
+
for(;;)
{
- wait(1.0);
+ term.printf("%c[2J", ESC); //clear screen
+ term.printf("%c[H", ESC); //move cursor to Home
- ard2pmod.get_time(&rtc_time);
- ard2pmod.get_calendar(&rtc_calendar);
-
- term.printf("\n\nRTC Date and Time = %d/%d/%d ",
- rtc_calendar.month, rtc_calendar.date, rtc_calendar.year);
+ //new epoch time fx
+ epoch_time = ard2pmod.get_epoch();
- if(rtc_time.mode)
- {
- if(rtc_time.am_pm)
- {
- term.printf(" %d:%d:%d PM",
- rtc_time.hours, rtc_time.minutes, rtc_time.seconds);
- }
- else
- {
- term.printf(" %d:%d:%d AM",
- rtc_time.hours, rtc_time.minutes, rtc_time.seconds);
- }
- }
- else
- {
- term.printf(" %d:%d:%d",
- rtc_time.hours, rtc_time.minutes, rtc_time.seconds);
- }
+ term.printf("\nTime as seconds since January 1, 1970 = %d\n", epoch_time);
+ term.printf("\nTime as a basic string = %s", ctime(&epoch_time));
+
+ strftime(buffer, 32, "%I:%M %p\n", localtime(&epoch_time));
+ term.printf("\nTime as a custom formatted string = %s", buffer);
+
+ wait(1.0);
}//loop
}
MAXREFDES72# Ard2Pmod Shield