This package contains a simple test of tests for various elements of the SmartBoard hardware, which is a simple baseboard designed for easy embedding. It is able to run both a semi-automatic test suite as well as allow interactive testing.

Dependencies:   EthernetNetIf NTPClient_NetServices mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ShowTime.c Source File

ShowTime.c

00001 /// @file ShowTime.cpp contains a couple of simple time printing apis
00002 ///
00003 /// APIs for showing the time from the RTC, or from a passed in value.
00004 ///
00005 /// @note Copyright © 2011 by Smartware Computing, all rights reserved.
00006 /// @author David Smart
00007 ///
00008 #include "mbed.h"
00009 #include "ShowTime.h"
00010 
00011 static int SignOf(const int i) {
00012     return (i >= 0) ? 1 : -1;
00013 }
00014 
00015 void ShowTime(int hOffset, int mOffset) {
00016     ShowTime(0, hOffset, mOffset);
00017 }
00018 
00019 void ShowTime(time_t tValue, int hOffset, int mOffset) {
00020     time_t ctTime;
00021     char timbuf[70];
00022 
00023     if (tValue == 0)
00024         tValue = time(NULL);
00025     ctTime = tValue + hOffset * 3600 + SignOf(hOffset) * mOffset * 60;
00026     strcpy(timbuf, ctime(&ctTime));
00027     timbuf[strlen(timbuf)-1] = '\0';
00028     printf("    %s (offset: %02i:%02i)\r\n", timbuf, hOffset, mOffset);
00029 }