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
Diff: Modules/DateModule.cpp
- Revision:
- 13:9641bc42db92
- Parent:
- 12:0fea8ebe6c1a
- Child:
- 15:d1eaddb363be
diff -r 0fea8ebe6c1a -r 9641bc42db92 Modules/DateModule.cpp
--- a/Modules/DateModule.cpp Sun Aug 10 16:01:43 2014 +0000
+++ b/Modules/DateModule.cpp Mon Aug 11 19:11:43 2014 +0000
@@ -6,10 +6,10 @@
DateModule::DateModule
(
- Adafruit_RGBLCDShield & in_cLCD,
- RTclock & in_cRTclock
+ Serial & in_cDisplay,
+ RTclock & in_cRTclock
)
- : Module(in_cLCD)
+ : Module(in_cDisplay)
, m_cRTclock(in_cRTclock)
{
}
@@ -20,8 +20,7 @@
void DateModule::change
(
- int in_nIndexX,
- int in_nCursorY,
+ size_t in_nIndex,
bool in_bUp
)
{
@@ -42,7 +41,7 @@
eYearSingle,
};
- switch (in_nIndexX)
+ switch (in_nIndex)
{
case eWeekDay: sTM.tm_wday += (in_bUp ? 1 : -1); break;
case eDayTen: sTM.tm_mday += (in_bUp ? 1 : -1) * 10; break;
@@ -72,23 +71,14 @@
}
}
-int DateModule::setCursor
-(
- int in_nIndex,
- int in_nCursorX,
- int in_nCursorY
-)
+int DateModule::getCursorOffset(size_t & inout_nIndex)
{
const int k_aCursor[] = { 2, 4, 5, 7, 8, 12, 13 };
- int nIndex = in_nIndex;
- if (nIndex < 0) nIndex = 0;
- if (nIndex >= _countof(k_aCursor)) nIndex = _countof(k_aCursor) - 1;
+ if ((int)inout_nIndex < 0) inout_nIndex = 0;
+ if (inout_nIndex >= _countof(k_aCursor)) inout_nIndex = _countof(k_aCursor) - 1;
- int nCursorX = k_aCursor[nIndex];
- m_cLCD.setCursor(in_nCursorX + nCursorX,in_nCursorY);
-
- return nIndex;
+ return k_aCursor[inout_nIndex];
}
void DateModule::show()
@@ -98,5 +88,5 @@
// 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);
+ m_cDisplay.printf ("%s %02i/%02i/%04i ", k_aWeekDays[sTM.tm_wday], sTM.tm_mday, sTM.tm_mon + 1, 1900 + sTM.tm_year);
}
