That code looks correct except for setTimeout(0); which does nothing I think.
I havn't used images so I wonder if reading them is too slow here. You could try code like this instead so you read images once when app starts and not every time it's drawn (this code is replacement for your daylight function):
var faceDaylight = require("Storage").read("FaceDaylight.gif");
var hourHandDay = require("Storage").read("HourHandDay.gif");
var minHandDay = require("Storage").read("MinHandDay.gif");
var secHandDay = require("Storage").read("SecHandDay.gif");
function daylight() {
var d = new Date();
var h = d.getHours() % 12 || 12;
//var time = (""+h).substr(-2) + ":" + ("0"+m).substr(-2);
var HoursAngle = (d.getHours()+(d.getMinutes()/60))/12 * twoPi - Pi;
var MinutesAngle = (d.getMinutes()/60) * twoPi - Pi;
//var SecondsAngle = (d.getSeconds()/60) * twoPi - Pi;
var SecondsAngle = (d.getSeconds()/60+d.getMilliseconds()/60000) * twoPi - Pi;
g.reset();
g.clear();
g.drawImage(faceDaylight);
//DateWindow
g.setFont("6x8");
g.setFontAlign(0,0);
g.setColor(0,0,0);
g.drawString(d.toISOString().substr(8,2), 138, 88, 0);
g.drawString(d.toISOString().substr(8,2), 139, 88, 0);
g.drawImage(hourHandDay,xc,yc,{scale:1,rotate:HoursAngle});
g.drawImage(minHandDay,xc,yc,{scale:1,rotate:MinutesAngle});
g.drawImage(secHandDay,xc,yc,{scale:1,rotate:SecondsAngle});
queueDraw();
}
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.
That code looks correct except for
setTimeout(0);
which does nothing I think.I havn't used images so I wonder if reading them is too slow here. You could try code like this instead so you read images once when app starts and not every time it's drawn (this code is replacement for your
daylight
function):And similar change for
nightglow
function.