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/DateModule.cpp
- Revision:
- 10:3fcab08717fc
- Child:
- 11:96146db429de
diff -r 1501fb01ded6 -r 3fcab08717fc Modules/DateModule.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Modules/DateModule.cpp Sun Aug 10 12:34:44 2014 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "DateModule.h"
+#include "time_helper.h"
+
+const char * k_aWeekDays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+
+DateModule::DateModule
+(
+ Adafruit_RGBLCDShield & in_cLCD,
+ RTclock & in_cRTclock
+)
+ : Module(in_cLCD)
+ , m_cRTclock(in_cRTclock)
+{
+}
+
+DateModule::~DateModule()
+{
+}
+
+int DateModule::setCursor
+(
+ int in_nIndex,
+ int in_nCursorX,
+ int in_nCursorY
+)
+{
+ const int k_aCursor[] = { 2, 4, 5, 7, 8, 10, 11, 12, 13 };
+
+ 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 DateModule::show()
+{
+ tm sTM;
+
+ // to get the current time information
+ if (!m_cRTclock.getTime(sTM)) GetTime(sTM);
+
+ m_cLCD.printf ("%s %02i/%02i/%04i ", k_aWeekDays[sTM.tm_wday], sTM.tm_mday, sTM.tm_mon + 1, 1900 + sTM.tm_year);
+}
