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: SX1276Lib AdaFruit_RGBLCD MCP23017 mbed
Fork of AdaFruit_RGBLCD by
Diff: Modules/TimeModule.cpp
- Revision:
- 11:96146db429de
- Parent:
- 10:3fcab08717fc
- Child:
- 13:9641bc42db92
diff -r 3fcab08717fc -r 96146db429de Modules/TimeModule.cpp
--- a/Modules/TimeModule.cpp Sun Aug 10 12:34:44 2014 +0000
+++ b/Modules/TimeModule.cpp Sun Aug 10 15:45:03 2014 +0000
@@ -29,7 +29,77 @@
TimeModule::~TimeModule()
{
}
+
+void TimeModule::change
+(
+ int in_nIndexX,
+ int in_nCursorY,
+ bool in_bUp
+)
+{
+ tm sTM;
+ // to get the current time information
+ if (!m_cRTclock.getTime(sTM)) GetTime(sTM);
+ bool bTwelveHour = m_cRTclock.isTwelveHour();
+
+ enum ETime
+ {
+ eHourTen = 0,
+ eHourSingle,
+ eMinTen,
+ eMinSingle,
+ eSecondTen,
+ eSecondSingle,
+ eAmPm,
+ };
+
+ switch (in_nIndexX)
+ {
+ case eHourTen: sTM.tm_hour += (in_bUp ? 1 : -1) * 10; break;
+ case eHourSingle: sTM.tm_hour += (in_bUp ? 1 : -1); break;
+ case eMinTen: sTM.tm_min += (in_bUp ? 1 : -1) * 10; break;
+ case eMinSingle: sTM.tm_min += (in_bUp ? 1 : -1); break;
+ case eSecondTen: sTM.tm_sec += (in_bUp ? 1 : -1) * 10; break;
+ case eSecondSingle: sTM.tm_sec += (in_bUp ? 1 : -1); break;
+ case eAmPm:
+ if (bTwelveHour)
+ {
+ if (in_bUp)
+ {
+ if (sTM.tm_hour >= 12) bTwelveHour = !bTwelveHour; else sTM.tm_hour += 12;
+ }
+ else
+ {
+ if (sTM.tm_hour >= 12) sTM.tm_hour -= 12; else bTwelveHour = !bTwelveHour;
+ }
+ }
+ else
+ {
+ bTwelveHour = !bTwelveHour;
+ if (in_bUp && sTM.tm_hour >= 12) sTM.tm_hour -= 12;
+ if (!in_bUp && sTM.tm_hour < 12) sTM.tm_hour += 12;
+ }
+ break;
+ }
+
+ if (sTM.tm_hour < 0) sTM.tm_hour = 0;
+ if (sTM.tm_hour > 23) sTM.tm_hour = 23;
+ if (sTM.tm_min < 0) sTM.tm_min = 0;
+ if (sTM.tm_hour > 59) sTM.tm_min = 59;
+ if (sTM.tm_sec < 0) sTM.tm_sec = 0;
+ if (sTM.tm_sec > 59) sTM.tm_sec = 59;
+
+ if (m_cRTclock.setTime(sTM,bTwelveHour))
+ {
+ m_cRTclock.mapTime();
+ }
+ else
+ {
+ SetTime(sTM);
+ }
+}
+
int TimeModule::setCursor
(
int in_nIndex,
