Skip to content

Commit f053271

Browse files
committed
Hacking on round clock, next need to use the same code as the other clocks, because this clock code is borken
1 parent 0f26ec2 commit f053271

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

roundclock/roundclock.ino

+26-11
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ static int16_t *last_cached_point;
5151

5252
void setup(void)
5353
{
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+
5465
WiFi.mode(WIFI_STA); // use only the WiFi 'station' mode
5566

5667
// Initialize Serial Monitor
@@ -65,7 +76,6 @@ void setup(void)
6576

6677
// Initialize a NTPClient to get time
6778
timeClient.begin();
68-
Serial.println(timeClient.getFormattedTime());
6979

7080
// Adjust for EST. Suck it.
7181
timeClient.setTimeOffset(-14400);
@@ -84,17 +94,14 @@ void setup(void)
8494
Serial.print("Seconds: ");
8595
Serial.println(currentSecond);
8696

87-
gfx->begin();
88-
gfx->fillScreen(BACKGROUND);
89-
9097
#ifdef TFT_BL
9198
pinMode(TFT_BL, OUTPUT);
9299
digitalWrite(TFT_BL, HIGH);
93100
#endif
94101

102+
gfx->fillScreen(BACKGROUND);
103+
95104
// init LCD constant
96-
w = gfx->width();
97-
h = gfx->height();
98105
if (w < h)
99106
{
100107
center = w / 2;
@@ -120,12 +127,13 @@ void setup(void)
120127
ss = currentSecond;
121128

122129
targetTime = ((millis() / 1000) + 1) * 1000;
123-
}
124130

125-
void loop()
126-
{
127131
timeClient.update();
128132

133+
drawTimeAndDate();
134+
}
135+
136+
void drawTimeAndDate() {
129137
String currenttime = String(hh) + ":";
130138
if (mm < 10) currenttime += "0";
131139
currenttime += String(mm);
@@ -140,21 +148,28 @@ void loop()
140148
String weekDay = weekDays[timeClient.getDay()];
141149
int monthDay = ptm->tm_mday;
142150
String currentDate = weekDay + " " + String(monthDay);
151+
Serial.println("Setting date to"); Serial.println(currentDate);
143152
gfx->setCursor(80, 145);
144153
gfx->setTextColor(ORANGE);
145154
gfx->setTextSize(2);
146155
gfx->println(currentDate);
156+
}
157+
158+
void loop()
159+
{
160+
timeClient.update();
147161

148162
unsigned long cur_millis = millis();
149163
if (cur_millis >= targetTime)
150164
{
151165
targetTime += 1000;
152166
ss++; // Advance second
153-
if (ss == 60)
167+
if (ss >= 60)
154168
{
155169
ss = 0;
156170
mm++; // Advance minute
157171
Serial.println("Advancing minute");
172+
drawTimeAndDate();
158173
if (mm > 59)
159174
{
160175
mm = 0;
@@ -193,7 +208,7 @@ void loop()
193208
// }
194209
}
195210

196-
delay(100);
211+
delay(250);
197212
}
198213

199214
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

Comments
 (0)