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/TitleModule.cpp
- Revision:
- 25:24654d08a99a
- Parent:
- 15:d1eaddb363be
--- a/Modules/TitleModule.cpp Wed Oct 08 16:42:17 2014 +0000
+++ b/Modules/TitleModule.cpp Thu Oct 09 08:03:20 2014 +0000
@@ -1,16 +1,41 @@
#include "mbed.h"
#include "TitleModule.h"
+#include "time_helper.h"
-TitleModule::TitleModule(Serial & in_cDisplay)
+TitleModule::TitleModule
+(
+ Serial & in_cDisplay,
+ RTclock & in_cRTclock
+)
: Module(in_cDisplay)
+ , m_cRTclock(in_cRTclock)
{
+ ::memset(&m_sLastTM,0,sizeof(m_sLastTM));
}
TitleModule::~TitleModule()
{
}
-void TitleModule::show(bool /*in_bRefresh*/)
+void TitleModule::show(bool in_bRefresh)
{
- m_cDisplay.printf("System Running");
+ tm sTM;
+
+ // to get the current time information
+ if (!m_cRTclock.getTime(sTM)) GetTime(sTM);
+
+ // if refreshing - only update if there's a change
+ if (in_bRefresh)
+ {
+ // Check for change based on hour (rest is irrelevant)
+ if (sTM.tm_hour == m_sLastTM.tm_hour) return;
+ }
+
+ // Ensure internal struct has new TM data
+ ::memcpy(&m_sLastTM,&sTM,sizeof(m_sLastTM));
+ if (sTM.tm_hour < 6) m_cDisplay.printf("Night Time ");
+ else if (sTM.tm_hour < 12) m_cDisplay.printf("Morning Time ");
+ else if (sTM.tm_hour < 18) m_cDisplay.printf("Afternoon Time ");
+ else if (sTM.tm_hour < 21) m_cDisplay.printf("Evening Time ");
+ else m_cDisplay.printf("Bedtime ");
}
