Skip to content

Commit

Permalink
Merge pull request #104 from hwiguna/CYD-RollingClock
Browse files Browse the repository at this point in the history
Erase Previous Date and Day Of Week prior to drawing new date/day of …
  • Loading branch information
witnessmenow authored Jan 1, 2024
2 parents c6e25a0 + ed91361 commit dc362aa
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions Examples/Projects/RollingClock/RollingClock.ino
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ int clockSize = 6;
int clockDatum = TL_DATUM;
uint16_t clockBackgroundColor = TFT_BLACK;
uint16_t clockFontColor = TFT_YELLOW;
int prevDay = 0;

void SetupCYD()
{
Expand Down Expand Up @@ -324,25 +325,32 @@ void DrawDate(time_t utc)
int mth = month(local);
int yr = year(local);

tft.setTextDatum(BC_DATUM);
char buffer[50];
if (NOT_US_DATE)
if (dd != prevDay)
{
sprintf(buffer, "%02d/%02d/%d", dd, mth, yr);
}
else
{
// MURICA!!
sprintf(buffer, "%02d/%02d/%d", mth, dd, yr);
}
tft.setTextDatum(BC_DATUM);
char buffer[50];
if (NOT_US_DATE)
{
sprintf(buffer, "%02d/%02d/%d", dd, mth, yr);
}
else
{
// MURICA!!
sprintf(buffer, "%02d/%02d/%d", mth, dd, yr);
}

tft.setTextSize(4);
tft.drawString(buffer, 320 / 2, 210);
tft.setTextSize(4);
int h = tft.fontHeight();
tft.fillRect(0, 210 - h, 320, h, TFT_BLACK);

int dow = weekday(local);
String dayNames[] = {"", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
tft.setTextSize(4);
tft.drawString(dayNames[dow], 320 / 2, 170);
tft.drawString(buffer, 320 / 2, 210);

int dow = weekday(local);
String dayNames[] = {"", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
tft.setTextSize(4);
tft.fillRect(0, 170 - h, 320, h, TFT_BLACK);
tft.drawString(dayNames[dow], 320 / 2, 170);
}
}

void SetupWiFi()
Expand Down

0 comments on commit dc362aa

Please sign in to comment.