CaryCoders / Mbed 2 deprecated demo_SX1276_standalone

Dependencies:   SX1276Lib mbed

Fork of SX1276_GPS by CaryCoders

Revision:
15:d1eaddb363be
Parent:
13:9641bc42db92
Child:
16:9e1edf28393f
--- a/Modules/DateModule.cpp	Mon Aug 11 19:13:08 2014 +0000
+++ b/Modules/DateModule.cpp	Tue Aug 12 04:25:08 2014 +0000
@@ -12,6 +12,7 @@
     : Module(in_cDisplay)
     , m_cRTclock(in_cRTclock)
 {
+    ::memset(&m_sLastTM,0,sizeof(m_sLastTM));
 }
 
 DateModule::~DateModule()
@@ -81,12 +82,20 @@
     return k_aCursor[inout_nIndex];
 }
 
-void DateModule::show()
+void DateModule::show(bool in_bRefresh)
 {
     tm sTM;
     
     // to get the current time information
     if (!m_cRTclock.getTime(sTM)) GetTime(sTM);
-
-    m_cDisplay.printf ("%s %02i/%02i/%04i      ", k_aWeekDays[sTM.tm_wday], sTM.tm_mday, sTM.tm_mon + 1, 1900 + sTM.tm_year);    
+    
+    // if refreshing - only update if there's a change
+    if (in_bRefresh)
+    {        
+        if (0 == ::memcmp(&sTM,&m_sLastTM,sizeof(sTM))) return;        
+    }
+    
+    // Ensure internal struct has new TM data
+    ::memcpy(&m_sLastTM,&sTM,sizeof(m_sLastTM));
+    m_cDisplay.printf ("%s %02i/%02i/%04i      ", k_aWeekDays[sTM.tm_wday], sTM.tm_mday, sTM.tm_mon + 1, 1900 + sTM.tm_year);
 }