Okay.... here's what I have:
const xc=88, yc=88; var twoPi = 2*Math.PI; var Pi = Math.PI; var halfPi = Math.PI/2; //daylight_images 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"); //nightglow_images var faceGlow = require("Storage").read("FaceGlow.gif"); var hourHandGlow = require("Storage").read("HourHandGlow.gif"); var minHandGlow = require("Storage").read("MinHandGlow.gif"); var secHandGlow = require("Storage").read("SecHandGlow.gif"); // var drawTimeout; function daylight() { var d = new Date(); var h = d.getHours() % 12 || 12; var HoursAngle = (d.getHours()+(d.getMinutes()/60))/12 * twoPi - Pi; var MinutesAngle = (d.getMinutes()/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(); } function nightglow() { var d = new Date(); var h = d.getHours() % 12 || 12; var HoursAngle = (d.getHours()+(d.getMinutes()/60))/12 * twoPi - Pi; var MinutesAngle = (d.getMinutes()/60) * twoPi - Pi; var SecondsAngle = (d.getSeconds()/60+d.getMilliseconds()/60000) * twoPi - Pi; g.reset(); g.clear(); g.drawImage(faceGlow); g.drawImage(hourHandGlow,xc,yc,{scale:1,rotate:HoursAngle}); g.drawImage(minHandGlow,xc,yc,{scale:1,rotate:MinutesAngle}); g.drawImage(secHandGlow,xc,yc,{scale:1,rotate:SecondsAngle}); queueDraw(); } function draw(){ if(Bangle.isLocked()){ daylight(); } else { nightglow(); } } function queueDraw() { if (drawTimeout) clearTimeout(drawTimeout); drawTimeout = setTimeout(() => { drawTimeout = undefined; draw(); }, 250 - (Date.now() % 250)); } Bangle.on('lock', on => { draw(); }); draw();
Still getting the tiniest delay, though I think it is better than it was.
@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.
Okay.... here's what I have:
Still getting the tiniest delay, though I think it is better than it was.