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: AdaFruit_RGBLCDShield MCP23017 mbed RTclock
Fork of MCP_test by
Revision 12:0fea8ebe6c1a, committed 2014-08-10
- Comitter:
- vtraveller
- Date:
- Sun Aug 10 16:01:43 2014 +0000
- Parent:
- 11:96146db429de
- Child:
- 13:9641bc42db92
- Commit message:
- Added Date Changing.
Changed in this revision
| Modules/DateModule.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Modules/DateModule.cpp Sun Aug 10 15:45:03 2014 +0000
+++ b/Modules/DateModule.cpp Sun Aug 10 16:01:43 2014 +0000
@@ -30,16 +30,46 @@
// to get the current time information
if (!m_cRTclock.getTime(sTM)) GetTime(sTM);
bool bTwelveHour = m_cRTclock.isTwelveHour();
+
+ enum ETime
+ {
+ eWeekDay = 0,
+ eDayTen,
+ eDaySingle,
+ eMonthTen,
+ eMonthSingle,
+ eYearTen,
+ eYearSingle,
+ };
-#if 0
switch (in_nIndexX)
{
- case 0: m_nTemp += (in_bUp ? 1 : -1) * 10; break;
- case 1: m_nTemp += (in_bUp ? 1 : -1); break;
+ case eWeekDay: sTM.tm_wday += (in_bUp ? 1 : -1); break;
+ case eDayTen: sTM.tm_mday += (in_bUp ? 1 : -1) * 10; break;
+ case eDaySingle: sTM.tm_mday += (in_bUp ? 1 : -1); break;
+ case eMonthTen: sTM.tm_mon += (in_bUp ? 1 : -1) * 10; break;
+ case eMonthSingle: sTM.tm_mon += (in_bUp ? 1 : -1); break;
+ case eYearTen: sTM.tm_year += (in_bUp ? 1 : -1) * 10; break;
+ case eYearSingle: sTM.tm_year += (in_bUp ? 1 : -1); break;
}
-#endif
+
+ if (sTM.tm_wday < 0) sTM.tm_wday = 0;
+ if (sTM.tm_wday > 6) sTM.tm_wday = 6;
+ if (sTM.tm_mday < 1) sTM.tm_mday = 1;
+ if (sTM.tm_mday > 31) sTM.tm_mday = 31;
+ if (sTM.tm_mon < 0) sTM.tm_mon = 0;
+ if (sTM.tm_mon > 11) sTM.tm_mon = 11;
+ if (sTM.tm_year < 2000 - 1900) sTM.tm_year = 2000 - 1900;
+ if (sTM.tm_year > 2099 - 1900) sTM.tm_year = 2099 - 1900;
- if (!m_cRTclock.setTime(sTM,bTwelveHour)) SetTime(sTM);
+ if (m_cRTclock.setTime(sTM,bTwelveHour))
+ {
+ m_cRTclock.mapTime();
+ }
+ else
+ {
+ SetTime(sTM);
+ }
}
int DateModule::setCursor
@@ -49,7 +79,7 @@
int in_nCursorY
)
{
- const int k_aCursor[] = { 2, 4, 5, 7, 8, 10, 11, 12, 13 };
+ const int k_aCursor[] = { 2, 4, 5, 7, 8, 12, 13 };
int nIndex = in_nIndex;
if (nIndex < 0) nIndex = 0;
