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
Modules/TitleModule.cpp
- Committer:
- vtraveller
- Date:
- 2014-10-09
- Revision:
- 25:24654d08a99a
- Parent:
- 15:d1eaddb363be
File content as of revision 25:24654d08a99a:
#include "mbed.h"
#include "TitleModule.h"
#include "time_helper.h"
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)
{
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 ");
}
