@@ -51,6 +51,17 @@ static int16_t *last_cached_point;
51
51
52
52
void setup (void )
53
53
{
54
+ w = gfx->width ();
55
+ h = gfx->height ();
56
+
57
+ gfx->begin ();
58
+ gfx->fillScreen (BACKGROUND);
59
+
60
+ gfx->setCursor (15 , h/2 -10 ); // x,y
61
+ gfx->setTextColor (GREEN);
62
+ gfx->setTextSize (3 );
63
+ gfx->println (" Connecting" );
64
+
54
65
WiFi.mode (WIFI_STA); // use only the WiFi 'station' mode
55
66
56
67
// Initialize Serial Monitor
@@ -65,7 +76,6 @@ void setup(void)
65
76
66
77
// Initialize a NTPClient to get time
67
78
timeClient.begin ();
68
- Serial.println (timeClient.getFormattedTime ());
69
79
70
80
// Adjust for EST. Suck it.
71
81
timeClient.setTimeOffset (-14400 );
@@ -84,17 +94,14 @@ void setup(void)
84
94
Serial.print (" Seconds: " );
85
95
Serial.println (currentSecond);
86
96
87
- gfx->begin ();
88
- gfx->fillScreen (BACKGROUND);
89
-
90
97
#ifdef TFT_BL
91
98
pinMode (TFT_BL, OUTPUT);
92
99
digitalWrite (TFT_BL, HIGH);
93
100
#endif
94
101
102
+ gfx->fillScreen (BACKGROUND);
103
+
95
104
// init LCD constant
96
- w = gfx->width ();
97
- h = gfx->height ();
98
105
if (w < h)
99
106
{
100
107
center = w / 2 ;
@@ -120,12 +127,13 @@ void setup(void)
120
127
ss = currentSecond;
121
128
122
129
targetTime = ((millis () / 1000 ) + 1 ) * 1000 ;
123
- }
124
130
125
- void loop ()
126
- {
127
131
timeClient.update ();
128
132
133
+ drawTimeAndDate ();
134
+ }
135
+
136
+ void drawTimeAndDate () {
129
137
String currenttime = String (hh) + " :" ;
130
138
if (mm < 10 ) currenttime += " 0" ;
131
139
currenttime += String (mm);
@@ -140,21 +148,28 @@ void loop()
140
148
String weekDay = weekDays[timeClient.getDay ()];
141
149
int monthDay = ptm->tm_mday ;
142
150
String currentDate = weekDay + " " + String (monthDay);
151
+ Serial.println (" Setting date to" ); Serial.println (currentDate);
143
152
gfx->setCursor (80 , 145 );
144
153
gfx->setTextColor (ORANGE);
145
154
gfx->setTextSize (2 );
146
155
gfx->println (currentDate);
156
+ }
157
+
158
+ void loop ()
159
+ {
160
+ timeClient.update ();
147
161
148
162
unsigned long cur_millis = millis ();
149
163
if (cur_millis >= targetTime)
150
164
{
151
165
targetTime += 1000 ;
152
166
ss++; // Advance second
153
- if (ss = = 60 )
167
+ if (ss > = 60 )
154
168
{
155
169
ss = 0 ;
156
170
mm++; // Advance minute
157
171
Serial.println (" Advancing minute" );
172
+ drawTimeAndDate ();
158
173
if (mm > 59 )
159
174
{
160
175
mm = 0 ;
@@ -193,7 +208,7 @@ void loop()
193
208
// }
194
209
}
195
210
196
- delay (100 );
211
+ delay (250 );
197
212
}
198
213
199
214
void draw_round_clock_mark (int16_t innerR1, int16_t outerR1, int16_t innerR2, int16_t outerR2, int16_t innerR3, int16_t outerR3)
0 commit comments