@@ -1200,10 +1200,22 @@ void DisplayUI::rDrawString( const char *str,
1200
1200
** Draws the current time using clock font and updates only when values change.
1201
1201
** ===================================================================
1202
1202
*/
1203
- void DisplayUI::drawClockTime (bool isForceRepaint)
1203
+ void DisplayUI::drawClockTime (bool isUSFormat, bool isForceRepaint)
1204
1204
{
1205
+ const int fontSize = 128 ;
1206
+ const int fontWidth = 76 ;
1205
1207
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
+ }
1207
1219
std::string minutes = getCurrentTimestamp (" %M" ).c_str ();
1208
1220
std::string ampm = getCurrentTimestamp (" %p" ).c_str ();
1209
1221
std::string seconds = getCurrentTimestamp (" %S" ).c_str ();
@@ -1212,51 +1224,55 @@ void DisplayUI::drawClockTime(bool isForceRepaint)
1212
1224
static std::string lastMinutes = " " ;
1213
1225
static std::string lastAmpm = " " ;
1214
1226
1215
- const int fontSize = 128 ;
1216
- const int fontWidth = 76 ;
1217
-
1227
+ // Hours
1218
1228
if ((lastHours != hours)
1219
1229
|| isForceRepaint)
1220
1230
{
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 ());
1223
1233
lastHours = hours;
1224
1234
}
1225
1235
1236
+ // Seconds indicator :
1226
1237
static bool isLastColonVisible = true ;
1227
1238
int iSeconds = std::stoi (seconds);
1228
1239
bool isCurrentColonVisible = (iSeconds % 2 == 0 );
1229
1240
if (isCurrentColonVisible != isLastColonVisible
1230
1241
|| isForceRepaint)
1231
1242
{
1232
- _tft->fillRect (180 , 53 , 35 , 84 , toValue (getBackground ()));
1243
+ _tft->fillRect (180 + offset , 53 , 35 , 84 , toValue (getBackground ()));
1233
1244
const char * colonChar = isCurrentColonVisible ? " :" : " " ;
1234
- drawClockString (colonChar, 160 , 20 , fontSize, TFTColor::Yellow, getBackground ());
1245
+ drawClockString (colonChar, 160 + offset , 20 , fontSize, TFTColor::Yellow, getBackground ());
1235
1246
isLastColonVisible = isCurrentColonVisible;
1236
1247
}
1237
1248
1249
+ // Minutes
1238
1250
if ((lastMinutes != minutes)
1239
1251
|| isForceRepaint)
1240
1252
{
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 ());
1243
1255
lastMinutes = minutes;
1244
1256
}
1245
1257
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
+ }
1260
1276
}
1261
1277
}
1262
1278
0 commit comments