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
Modules/DateModule.cpp@10:3fcab08717fc, 2014-08-10 (annotated)
- Committer:
- vtraveller
- Date:
- Sun Aug 10 12:34:44 2014 +0000
- Revision:
- 10:3fcab08717fc
- Child:
- 11:96146db429de
Added module system.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| vtraveller | 10:3fcab08717fc | 1 | #include "mbed.h" |
| vtraveller | 10:3fcab08717fc | 2 | #include "DateModule.h" |
| vtraveller | 10:3fcab08717fc | 3 | #include "time_helper.h" |
| vtraveller | 10:3fcab08717fc | 4 | |
| vtraveller | 10:3fcab08717fc | 5 | const char * k_aWeekDays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; |
| vtraveller | 10:3fcab08717fc | 6 | |
| vtraveller | 10:3fcab08717fc | 7 | DateModule::DateModule |
| vtraveller | 10:3fcab08717fc | 8 | ( |
| vtraveller | 10:3fcab08717fc | 9 | Adafruit_RGBLCDShield & in_cLCD, |
| vtraveller | 10:3fcab08717fc | 10 | RTclock & in_cRTclock |
| vtraveller | 10:3fcab08717fc | 11 | ) |
| vtraveller | 10:3fcab08717fc | 12 | : Module(in_cLCD) |
| vtraveller | 10:3fcab08717fc | 13 | , m_cRTclock(in_cRTclock) |
| vtraveller | 10:3fcab08717fc | 14 | { |
| vtraveller | 10:3fcab08717fc | 15 | } |
| vtraveller | 10:3fcab08717fc | 16 | |
| vtraveller | 10:3fcab08717fc | 17 | DateModule::~DateModule() |
| vtraveller | 10:3fcab08717fc | 18 | { |
| vtraveller | 10:3fcab08717fc | 19 | } |
| vtraveller | 10:3fcab08717fc | 20 | |
| vtraveller | 10:3fcab08717fc | 21 | int DateModule::setCursor |
| vtraveller | 10:3fcab08717fc | 22 | ( |
| vtraveller | 10:3fcab08717fc | 23 | int in_nIndex, |
| vtraveller | 10:3fcab08717fc | 24 | int in_nCursorX, |
| vtraveller | 10:3fcab08717fc | 25 | int in_nCursorY |
| vtraveller | 10:3fcab08717fc | 26 | ) |
| vtraveller | 10:3fcab08717fc | 27 | { |
| vtraveller | 10:3fcab08717fc | 28 | const int k_aCursor[] = { 2, 4, 5, 7, 8, 10, 11, 12, 13 }; |
| vtraveller | 10:3fcab08717fc | 29 | |
| vtraveller | 10:3fcab08717fc | 30 | int nIndex = in_nIndex; |
| vtraveller | 10:3fcab08717fc | 31 | if (nIndex < 0) nIndex = 0; |
| vtraveller | 10:3fcab08717fc | 32 | if (nIndex >= _countof(k_aCursor)) nIndex = _countof(k_aCursor) - 1; |
| vtraveller | 10:3fcab08717fc | 33 | |
| vtraveller | 10:3fcab08717fc | 34 | int nCursorX = k_aCursor[nIndex]; |
| vtraveller | 10:3fcab08717fc | 35 | m_cLCD.setCursor(in_nCursorX + nCursorX,in_nCursorY); |
| vtraveller | 10:3fcab08717fc | 36 | |
| vtraveller | 10:3fcab08717fc | 37 | return nIndex; |
| vtraveller | 10:3fcab08717fc | 38 | } |
| vtraveller | 10:3fcab08717fc | 39 | |
| vtraveller | 10:3fcab08717fc | 40 | void DateModule::show() |
| vtraveller | 10:3fcab08717fc | 41 | { |
| vtraveller | 10:3fcab08717fc | 42 | tm sTM; |
| vtraveller | 10:3fcab08717fc | 43 | |
| vtraveller | 10:3fcab08717fc | 44 | // to get the current time information |
| vtraveller | 10:3fcab08717fc | 45 | if (!m_cRTclock.getTime(sTM)) GetTime(sTM); |
| vtraveller | 10:3fcab08717fc | 46 | |
| vtraveller | 10:3fcab08717fc | 47 | m_cLCD.printf ("%s %02i/%02i/%04i ", k_aWeekDays[sTM.tm_wday], sTM.tm_mday, sTM.tm_mon + 1, 1900 + sTM.tm_year); |
| vtraveller | 10:3fcab08717fc | 48 | } |
