diff --git a/.gitignore b/.gitignore index f1811806d..abc3e9bd1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules package-lock.json .DS_Store +*.js.bak diff --git a/apps.json b/apps.json index 0d5d96d13..a1a8ad675 100644 --- a/apps.json +++ b/apps.json @@ -108,7 +108,7 @@ { "id": "mclock", "name": "Morphing Clock", "icon": "clock-morphing.png", - "version":"0.04", + "version":"0.05", "description": "7 segment clock that morphs between minutes and hours", "tags": "clock", "type":"clock", diff --git a/apps/mclock/ChangeLog b/apps/mclock/ChangeLog index 4bc1ea352..98566f277 100644 --- a/apps/mclock/ChangeLog +++ b/apps/mclock/ChangeLog @@ -1,3 +1,5 @@ 0.02: Modified for use with new bootloader and firmware 0.03: Added Locale based date 0.04: Improve performance, attempt to remove occasional glitch when LCD on (fix #279) +0.05: Add "ram" keyword to allow 2v06 Espruino builds to cache function that needs to be fast + Fix issue where first digit could get stuck going from "2x:xx" to " x:xx" (fix #365) diff --git a/apps/mclock/clock-morphing-faster.js b/apps/mclock/clock-morphing-faster.js deleted file mode 100644 index 69cd72707..000000000 --- a/apps/mclock/clock-morphing-faster.js +++ /dev/null @@ -1,206 +0,0 @@ -var locale = require("locale"); -var CHARW = 34; -var CHARP = 2; -var Y = 50; -// Offscreen buffer -var buf = Graphics.createArrayBuffer(CHARW+CHARP*2,CHARW*2 + CHARP*2,1,{msb:true}); -var bufimg = {width:buf.getWidth(),height:buf.getHeight(),buffer:buf.buffer}; -// The last time that we displayed -var lastTime = " "; -// If animating, this is the interval's id -var animInterval; -var timeInterval; - -/* Get array of lines from digit d to d+1. - n is the amount (0..1) - maxFive is true is this digit only counts 0..5 */ -const DIGITS = { -" ":(g,s,p,n)=>{}, -"0":(g,s,p,n)=>{ -g.fillRect(1+s*n,1-p, 1+s,1+p); -g.fillRect(1+s-p,1, 1+s+p,1+s); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1+s*n,1+2*s-p, 1+s,1+2*s+p); -g.fillRect(1+s*n,1+s-p, 1+s*n,1+2*s+p); -g.fillRect(1+s*n-p,1, 1+s*n+p,1+s)}, -"1":(g,s,p,n)=>{ -g.fillRect(1+(1-n)*s,1-p, 1+s,1+p); -g.fillRect(1+s-p,1, 1+s+p,1+s); -g.fillRect(1+(1-n)*s,1+s-p, 1+s,1+s+p); -g.fillRect(1-p+(1-n)*s,1+s, 1+p+(1-n)*s,1+2*s); -g.fillRect(1+(1-n)*s,1-p+2*s, 1+s,1+p+2*s)}, -"2":(g,s,p,n)=>{ -g.fillRect(1,1-p, 1+s,1+p); -g.fillRect(1+s-p,1, 1+s+p,1+s); -g.fillRect(1,1+s-p, 1+s,1+s+p); -g.fillRect(1-p,1+(1+n)*s, 1+p,1+2*s); -g.fillRect(1+s-p,1+(2-n)*s, 1+s+p,1+2*s); -g.fillRect(1,1+2*s-p, 1+s,1+2*s+p)}, -"3":(g,s,p,n)=>{ -g.fillRect(1,1-p, 1+(1-n)*s,1+p); -g.fillRect(1-p,1, 1+p,n); -g.fillRect(1+s-p,1, 1+s+p,1+s); -g.fillRect(1,1+s-p, 1+s,1+s+p); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1+s*n,1+2*s-p, 1+s,1+2*s+p)}, -"4":(g,s,p,n)=>{ -g.fillRect(1-p,1, 1+p,1+s); -g.fillRect(1+s,1-p, 1+(1-n)*s,1+p); -g.fillRect(1+s-p,1, 1+s+p,1+(1-n)*s); -g.fillRect(1,1+s-p, 1+s,1+s+p); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1+(1-n)*s,1+2*s-p, 1+s,1+2*s+p)}, -"5to0": (g,s,p,n)=>{ // 5 -> 0 -g.fillRect(1-p,1, 1+p,1+s); -g.fillRect(1,1-p, 1+s,1+p); -g.fillRect(1+s*n,1+s-p, 1+s,1+s+p); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1,1+2*s*p, 1+s,1+2*s+p); -g.fillRect(1,1+2*s-p, 1,1+2*s+p); -g.fillRect(1+s-p,1+(1-n)*s, 1+s+p,1+s); -g.fillRect(1-p,1+s, 1+p,1+(1+n)*s)}, -"5to6": (g,s,p,n)=>{ // 5 -> 6 -g.fillRect(1-p,1, 1+p,1+s); -g.fillRect(1,1-p, 1+s,1+p); -g.fillRect(1,1+s-p, 1+s,1+s+p); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1,1+2*s-p, 1+s,1+2*s+p); -g.fillRect(1-p,2-n, 1+p,1+2*s)}, -"6":(g,s,p,n)=>{ -g.fillRect(1-p,1, 1+p,1+(1-n)*s); -g.fillRect(1,1-p, 1+s,1+p); -g.fillRect(1+s*n,1+s-p, 1+s,1+s+p); -g.fillRect(1+s-p,1+(1-n)*s, 1+s+p,1+s); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1+s*n,1+2*s-p, 1+s,1+2*s+p); -g.fillRect(1-p,1+(1-n)*s, 1+p,1+s*(2-2*n))}, -"7":(g,s,p,n)=>{ -g.fillRect(1-p,1, 1+p,n); -g.fillRect(1,1-p, 1+s,1+p); -g.fillRect(1+s-p,1, 1+s+p,1+s); -g.fillRect(1+(1-n)*s,1+s-p, 1+s,1+s+p); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1+(1-n)*s,1+2*s-p, 1+s,1+2*s+p); -g.fillRect(1+(1-n)*s-p,1+s, 1+(1-n)*s+p,1+2*s)}, -"8":(g,s,p,n)=>{ -g.fillRect(1-p,1, 1+p,1+s); -g.fillRect(1,1-p, 1+s,1+p); -g.fillRect(1+s-p,1, 1+s+p,1+s); -g.fillRect(1,1+s-p, 1+s,1+s+p); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1,1+2*s-p, 1+s,1+2*s+p); -g.fillRect(1-p,1+s, 1+p,1+s*(2-n))}, -"9":(g,s,p,n)=>{ -g.fillRect(1-p,1, 1+p,1+s); -g.fillRect(1,1-p, 1+s,1+p); -g.fillRect(1+s-p,1, 1+s+p,1+s); -g.fillRect(1,1+s-p, 1+(1-n)*s,1+s+p); -g.fillRect(1-p,1+s, 1+p,1+(1+n)*s); -g.fillRect(1+s-p,1+s, 1+s+p,1+2*s); -g.fillRect(1,1+2*s-p, 1+s,1+2*s+p)}, -":":(g,s,p,n)=>{ -g.fillRect(1+s*0.4,1+s*0.4-p, 1+s*0.6,1+s*0.4+p); -g.fillRect(1+s*0.6-p,1+s*0.4, 1+s*0.6+p,1+s*0.6); -g.fillRect(1+s*0.6,1+s*0.6-p, 1+s*0.4,1+s*0.6+p); -g.fillRect(1+s*0.4-p,1+s*0.4, 1+s*0.4+p,1+s*0.6); -g.fillRect(1+s*0.4,1+s*1.4-p, 1+s*0.6,1+s*1.4+p); -g.fillRect(1+s*0.6-p,1+s*1.4, 1+s*0.6+p,1+s*1.6); -g.fillRect(1+s*0.6,1+s*1.6-p, 1+s*0.4,1+s*1.6+p); -g.fillRect(1+s*0.4-p,1+s*1.4, 1+s*0.4+p,1+s*1.6) -}}; - -/* Draw a transition between lastText and thisText. - 'n' is the amount - 0..1 */ -function drawDigits(lastText,thisText,n) { - const p = CHARP; // padding around digits - const s = CHARW; // character size - var x = p; // x offset - var y = Y+p; // y offset - g.reset(); - for (var i=0;i=1) { - n=1; - clearInterval(animInterval); - animInterval = undefined; - } - drawDigits(l,t,n); - }, 20); - lastTime = t; -} - -Bangle.on('lcdPower',function(on) { - if (animInterval) { - clearInterval(animInterval); - animInterval = undefined; - } - if (timeInterval) { - clearInterval(timeInterval); - timeInterval = undefined; - } - if (on) { - showTime(); - timeInterval = setInterval(showTime, 1000); - } -}); - -g.clear(); -Bangle.loadWidgets(); -Bangle.drawWidgets(); -// Update time once a second -timeInterval = setInterval(showTime, 1000); -showTime(); - -// Show launcher when middle button pressed -setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); diff --git a/apps/mclock/clock-morphing.js b/apps/mclock/clock-morphing.js index e9365db52..8a2c62e28 100644 --- a/apps/mclock/clock-morphing.js +++ b/apps/mclock/clock-morphing.js @@ -6,7 +6,7 @@ var Y = 50; // start height var buf = Graphics.createArrayBuffer(CHARW+CHARP*2,CHARW*2 + CHARP*2,1,{msb:true}); var bufimg = {width:buf.getWidth(),height:buf.getHeight(),buffer:buf.buffer}; // The last time that we displayed -var lastTime = " "; +var lastTime = "-----"; // If animating, this is the interval's id var animInterval; var timeInterval; @@ -112,6 +112,7 @@ const DIGITS = { /* Draw a transition between lastText and thisText. 'n' is the amount - 0..1 */ function drawDigits(lastText,thisText,n) { + "ram" const p = CHARP; // padding around digits const s = CHARW; // character size var x = 0; // x offset @@ -167,7 +168,7 @@ function showTime() { ("0"+d.getMinutes()).substr(-2); var l = lastTime; // same - don't animate - if (t==l || l==" ") { + if (t==l || l=="-----") { drawDigits(l,t,0); drawSeconds(); lastTime = t; @@ -199,7 +200,7 @@ Bangle.on('lcdPower',function(on) { showTime(); timeInterval = setInterval(showTime, 1000); } else { - lastTime = " "; + lastTime = "-----"; } });