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:
- 10:3fcab08717fc
- Child:
- 11:96146db429de
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Modules/TimeModule.cpp Sun Aug 10 12:34:44 2014 +0000
@@ -0,0 +1,74 @@
+#include "mbed.h"
+#include "TimeModule.h"
+#include "time_helper.h"
+
+#if 0
+ tm sTM;
+ sTM.tm_sec = 0;
+ sTM.tm_min = 0;
+ sTM.tm_hour = 18;
+ sTM.tm_mday = 9;
+ sTM.tm_mon = 8 - 1;
+ sTM.tm_year = 2014 - 1900;
+ sTM.tm_wday = 6;
+
+ rtc.SetTime(sTM,true);
+#endif
+
+
+TimeModule::TimeModule
+(
+ Adafruit_RGBLCDShield & in_cLCD,
+ RTclock & in_cRTclock
+)
+ : Module(in_cLCD)
+ , m_cRTclock(in_cRTclock)
+{
+}
+
+TimeModule::~TimeModule()
+{
+}
+
+int TimeModule::setCursor
+(
+ int in_nIndex,
+ int in_nCursorX,
+ int in_nCursorY
+)
+{
+ const int k_aCursor[] = { 0, 1, 3, 4, 6, 7, 10 };
+
+ int nIndex = in_nIndex;
+ if (nIndex < 0) nIndex = 0;
+ if (nIndex >= _countof(k_aCursor)) nIndex = _countof(k_aCursor) - 1;
+
+ int nCursorX = k_aCursor[nIndex];
+ m_cLCD.setCursor(in_nCursorX + nCursorX,in_nCursorY);
+
+ return nIndex;
+}
+
+void TimeModule::show()
+{
+ tm sTM;
+ const char * pUnits = " ";
+
+ // to get the current time information
+ if (m_cRTclock.getTime(sTM))
+ {
+ // Adjust for 12 hour clock
+ if (m_cRTclock.isTwelveHour())
+ {
+ pUnits = (sTM.tm_hour < 12) ? "am":"pm";
+ sTM.tm_hour %= 12;
+ }
+ }
+ else
+ {
+ // If failed get internal time (as at least that's something
+ GetTime(sTM);
+ }
+
+ m_cLCD.printf ("%02i:%02i:%02i %s ", sTM.tm_hour, sTM.tm_min, sTM.tm_sec, pUnits);
+}
