@@ -1200,10 +1200,22 @@ void DisplayUI::rDrawString( const char  *str,
12001200**    Draws the current time using clock font and updates only when values change. 
12011201** =================================================================== 
12021202*/ 
1203- void  DisplayUI::drawClockTime (bool  isForceRepaint)
1203+ void  DisplayUI::drawClockTime (bool  isUSFormat,  bool   isForceRepaint)
12041204{
1205+     const  int  fontSize  = 128 ;
1206+     const  int  fontWidth = 76 ;
12051207
1206-     std::string hours   = getCurrentTimestamp (" %l"  ).c_str ();  
1208+     int  offset          = 0 ;
1209+     std::string hours   = " "  ;
1210+     if  (isUSFormat)
1211+     {
1212+         hours  = getCurrentTimestamp (" %l"  ).c_str ();  
1213+     }
1214+     else 
1215+     {
1216+         hours  = getCurrentTimestamp (" %H"  ).c_str ();
1217+         offset = 50 ;
1218+     }
12071219    std::string minutes = getCurrentTimestamp (" %M"  ).c_str ();  
12081220    std::string ampm    = getCurrentTimestamp (" %p"  ).c_str ();  
12091221    std::string seconds = getCurrentTimestamp (" %S"  ).c_str ();
@@ -1212,51 +1224,55 @@ void DisplayUI::drawClockTime(bool isForceRepaint)
12121224    static  std::string lastMinutes = " "  ;
12131225    static  std::string lastAmpm    = " "  ;
12141226
1215-     const  int  fontSize  = 128 ;
1216-     const  int  fontWidth = 76 ;
1217- 
1227+     //  Hours
12181228    if  ((lastHours != hours)
12191229    ||  isForceRepaint)
12201230    {
1221-         _tft->fillRect (20 , 35 , fontWidth * 2 , 100 , toValue (getBackground ())); 
1222-         drawClockString (hours.c_str (), 20 , 25 , fontSize, TFTColor::White, getBackground ());   
1231+         _tft->fillRect (20  + offset , 35 , fontWidth * 2 , 100 , toValue (getBackground ())); 
1232+         drawClockString (hours.c_str (), 20  + offset , 25 , fontSize, TFTColor::White, getBackground ());   
12231233        lastHours = hours;     
12241234    }
12251235
1236+     //  Seconds indicator :
12261237    static  bool  isLastColonVisible      = true ;
12271238    int          iSeconds              = std::stoi (seconds);
12281239    bool         isCurrentColonVisible = (iSeconds % 2  == 0 );
12291240    if  (isCurrentColonVisible != isLastColonVisible 
12301241    ||  isForceRepaint)
12311242    {
1232-         _tft->fillRect (180 , 53 , 35 , 84 , toValue (getBackground ())); 
1243+         _tft->fillRect (180  + offset , 53 , 35 , 84 , toValue (getBackground ())); 
12331244        const  char * colonChar = isCurrentColonVisible ? " :"   : "  "  ;
1234-         drawClockString (colonChar, 160 , 20 , fontSize, TFTColor::Yellow, getBackground ());
1245+         drawClockString (colonChar, 160  + offset , 20 , fontSize, TFTColor::Yellow, getBackground ());
12351246        isLastColonVisible = isCurrentColonVisible;
12361247    }
12371248
1249+     //  Minutes
12381250    if  ((lastMinutes != minutes)
12391251    ||  isForceRepaint)
12401252    {  
1241-         _tft->fillRect (225 , 35 , fontWidth * 2 , 100 , toValue (getBackground ())); 
1242-         drawClockString (minutes.c_str (), 220 , 25 , fontSize, TFTColor::White, getBackground ());
1253+         _tft->fillRect (225  + offset , 35 , fontWidth * 2 , 100 , toValue (getBackground ())); 
1254+         drawClockString (minutes.c_str (), 220  + offset , 25 , fontSize, TFTColor::White, getBackground ());
12431255        lastMinutes = minutes;     
12441256    }
12451257
1246-     if  ((lastAmpm != ampm)
1247-     ||  isForceRepaint)
1248-     { 
1249-         _tft->fillRect (380 , 40 , fontWidth, 100 , toValue (getBackground ())); // toValue(getBackground())); 
1250-         if  (ampm == " AM"  )
1251-         {
1252-             drawClockString (ampm.c_str (), 380 , 35 , fontSize / 2 , TFTColor::Yellow, getBackground ());
1253-         }  
1254-         else 
1255-         {
1256-             drawClockString (ampm.c_str (), 380 , 80 , fontSize / 2 , TFTColor::Yellow, getBackground ());           
1257-         } 
1258- 
1259-         lastAmpm = ampm;     
1258+     //  AM/PM if US Format
1259+     if  (isUSFormat)
1260+     {
1261+         if  ((lastAmpm != ampm)
1262+         ||  isForceRepaint)
1263+         { 
1264+             _tft->fillRect (380 , 40 , fontWidth, 100 , toValue (getBackground ())); // toValue(getBackground())); 
1265+             if  (ampm == " AM"  )
1266+             {
1267+                 drawClockString (ampm.c_str (), 380 , 35 , fontSize / 2 , TFTColor::Yellow, getBackground ());
1268+             }  
1269+             else 
1270+             {
1271+                 drawClockString (ampm.c_str (), 380 , 80 , fontSize / 2 , TFTColor::Yellow, getBackground ());           
1272+             } 
1273+ 
1274+             lastAmpm = ampm;     
1275+         }
12601276    }
12611277}
12621278
0 commit comments