I changed the code to this:
setTimeout(function() { setInterval(draw,60000); }, 60000 - Date.now() % 60000);
I also put this line in draw() to measure the timing error:
g.setFontAlign(0,1).drawString(parseInt(((Date.now()+30000)%60000)-30000)/1000,g.getWidth()/2,24+18);
So far it has never shown more than 0.01s, which is good enough for a clock that updates every minute.
@RaoulDuke started
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.
I changed the code to this:
I also put this line in draw() to measure the timing error:
So far it has never shown more than 0.01s, which is good enough for a clock that updates every minute.