8 const int MONTHS[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
13 Serial.printf(
"TZ: %s\r\n", time_zone);
14 setenv(
"TZ", time_zone, 1);
16 if (!getLocalTime(&timeinfo)) {
17 Serial.println(
"Failed to obtain time. Retrying...");
26 epoch = mktime(&timeinfo);
35 uint16_t y =
year - a;
38 day_offset = (1 + y + (y / 4) - (y / 100) + (y / 400) + ((31 * m) / 12)) % 7;
54 Serial.printf(
"Time is %d %d:%d:%d on %s on the %d/%d/%d . It is the month of %s. day_offset: %d\r\n",
mil_hour,
hour,
min,
sec,
wday,
mday,
month_num,
year,
month,
day_offset);
61 uint16_t wt, ht, prev_height = 0, prev_width = 0;
64 display.setFont(
font);
66 display.setTextSize(1);
69 display.getTextBounds(
wday, 0, 0, &xt, &yt, &wt, &ht);
70 display.setCursor(x + ((w - wt) / 2), y + ht);
71 display.println(
wday);
72 prev_height += y + ht;
76 display.getTextBounds(date_str, 0, 0, &xt, &yt, &wt, &ht);
77 display.setCursor(x + ((w - wt) / 2), prev_height + ht + 20);
78 display.println(date_str);
84 uint16_t wt, ht, prev_height = 0, prev_width = 0;
87 display.setFont(
font);
89 display.setTextSize(1);
93 display.getTextBounds(mday_str, 0, 0, &xt, &yt, &wt, &ht);
94 display.setCursor(x + ((w - wt) / 2), y + ht);
95 display.println(mday_str);
96 prev_height += y + ht;
100 display.setCursor(x + ((w - wt) / 2), prev_height + ht + 5);
107 uint16_t wt, ht, prev_height = 0, prev_width = 0;
108 char time_str[] =
"Updated at: XX:XX";
110 display.setFont(
font);
112 display.setTextSize(1);
114 sprintf(&time_str[12],
"%02d:%02d",
mil_hour,
min);
115 display.getTextBounds(time_str, 0, 0, &xt, &yt, &wt, &ht);
116 display.setCursor(x + ((w - wt) / 2), y + ht);
117 display.print(time_str);
128 display.setFont(&Gobold_Thin9pt7b);
129 display.setTextSize(1);
132#define CAL_STRING "Mon Tue Wed Thu Fri Sat Sun"
134 display.setCursor(x, y);
136 display.getTextBounds(
CAL_STRING, 0, 0, &xt, &yt, &wt, &ht);
137 uint8_t num_offset, print_valid = 0;
140 for (uint8_t j = 0; j <= 5; j++) {
141 for (uint8_t i = 1; i <= 7 && day <=
month_days; i++) {
144 if (i >= 3 && i <= 7)
150 display.setCursor(x + (i * (wt / 7)) - num_offset, y + ((j + 1) * ht) + ((j + 1) * 7));
153 sprintf(str,
"%d", day);
156 display.getTextBounds(str, x + (i * (wt / 7)) - num_offset, y + ((j + 1) * ht) + ((j + 1) * 7), &x2, &y2, &w2, &h2);
157 display.fillRect(x2 - 4, y2 - 4, w2 + 8, h2 + 8,
primary_color);
163 display.println(day);