Justin Howard / Mbed 2 deprecated AdaFruit_RGBLCD

Dependencies:   AdaFruit_RGBLCDShield MCP23017 mbed RTclock

Dependents:   SX1276_GPS

Fork of MCP_test by Wim Huiskamp

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TitleModule.cpp Source File

TitleModule.cpp

00001 #include "mbed.h"
00002 #include "TitleModule.h"
00003 #include "time_helper.h"
00004 
00005 TitleModule::TitleModule
00006 (
00007     Serial &    in_cDisplay,
00008     RTclock &   in_cRTclock
00009 )
00010     : Module(in_cDisplay)
00011     , m_cRTclock(in_cRTclock)
00012 {
00013     ::memset(&m_sLastTM,0,sizeof(m_sLastTM));
00014 }
00015 
00016 TitleModule::~TitleModule()
00017 {
00018 }
00019 
00020 void TitleModule::show(bool in_bRefresh)
00021 {
00022     tm sTM;
00023     
00024     // to get the current time information
00025     if (!m_cRTclock.getTime(sTM)) GetTime(sTM);
00026     
00027     // if refreshing - only update if there's a change
00028     if (in_bRefresh)
00029     {
00030         // Check for change based on hour (rest is irrelevant)
00031         if (sTM.tm_hour == m_sLastTM.tm_hour) return;
00032     }
00033     
00034     // Ensure internal struct has new TM data
00035     ::memcpy(&m_sLastTM,&sTM,sizeof(m_sLastTM));
00036     if (sTM.tm_hour < 6) m_cDisplay.printf("Night Time       ");
00037     else if (sTM.tm_hour < 12) m_cDisplay.printf("Morning Time      ");
00038     else if (sTM.tm_hour < 18) m_cDisplay.printf("Afternoon Time    ");
00039     else if (sTM.tm_hour < 21) m_cDisplay.printf("Evening Time      ");
00040     else m_cDisplay.printf("Bedtime           ");
00041 }