Well, it can be also 59 seconds too late, so why not schedule timeout to the first second of the minute?
Even if you would run the first setInterval(draw,60000); at the right time - first second of the minute I am not sure how accurate interval is over time. With setTimeout you can compensate for that and also when time changes.
Clocks showing seconds can to the same and schedule to first milisecond in a second instead of e.g. running setInterval every 500 or 250ms.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Well, it can be also 59 seconds too late, so why not schedule timeout to the first second of the minute?
Even if you would run the first
setInterval(draw,60000);
at the right time - first second of the minute I am not sure how accurate interval is over time. With setTimeout you can compensate for that and also when time changes.Clocks showing seconds can to the same and schedule to first milisecond in a second instead of e.g. running setInterval every 500 or 250ms.