Making a clock [Help]


I would like to display/refresh 3 different data on the panel, like the image below:
(date, time, cronometer)

To get to the result showed on the image with another library i made the following:

if (millis()%1000 == 0) //enters here each second

But indexedLayer.swapBuffers(); does not work with the if (millis()%1000 == 0), it does not enters here each second so, how could i do that?


Your code would only work if you did the check during the 1 millisecond window where millis() ends in 000. You should check instead to see if the delay is equal to or greater than 1000. e.g.

if (currentMillis - blinkStartMillis >= blinkPeriod) //test whether the period has elapsed

More details here:

Thanks. It seems to work.
But the main problem remains: Looks like i cant use time library with SmartMatrix, like if both re using the same timer.
Im just trying to:

currentMillis = millis();
if (currentMillis - startMillis >= period)
indexedLayer.drawString(0, 0, 1, hour);

But as the LocalTime is being executed it out of blue goes to another part of the code, like a goto.

Any ideas?

I just want to make a clock (without using external RTC if possible)

Looks like NTP gets the job done. Thanks anyway.