Of course! Here is my entire code:
const xc=88, yc=88; var twoPi = 2*Math.PI; var Pi = Math.PI; var halfPi = Math.PI/2; 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(require("Storage").read("FaceDaylight.gif")); //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(require("Storage").read("HourHandDay.gif"),xc,yc,{scale:1,rotate:HoursAngle}); g.drawImage(require("Storage").read("MinHandDay.gif"),xc,yc,{scale:1,rotate:MinutesAngle}); g.drawImage(require("Storage").read("SecHandDay.gif"),xc,yc,{scale:1,rotate:SecondsAngle}); queueDraw(); } function nightglow() { var d = new Date(); var h = d.getHours() % 12 || 12, m = d.getMinutes(), yyyy = d.getFullYear(), mm = d.getMonth(), dd = d.getDate(); //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(require("Storage").read("FaceGlow.gif")); //DateWindow g.setFont("6x8"); g.setFontAlign(0,0); g.setColor(0,0,0); g.drawString(dd, 137, 88, 0); g.drawString(dd, 138, 88, 0); g.drawImage(require("Storage").read("HourHandGlow.gif"),xc,yc,{scale:1,rotate:HoursAngle}); g.drawImage(require("Storage").read("MinHandGlow.gif"),xc,yc,{scale:1,rotate:MinutesAngle}); g.drawImage(require("Storage").read("SecHandGlow.gif"),xc,yc,{scale:1,rotate:SecondsAngle}); queueDraw(); } function draw(){ if(Bangle.isLocked()){ daylight(); } else { nightglow(); } } var drawTimeout; function queueDraw() { if (drawTimeout) clearTimeout(drawTimeout); drawTimeout = setTimeout(() => { drawTimeout = undefined; draw(); }, 250 - (Date.now() % 250)); } Bangle.on('lock', on => { setTimeout(0); draw(); }); draw();
@NoMusicTuesdays 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.
Of course! Here is my entire code: