update multiclock

master
Jeff Magee 2021-01-11 07:16:58 +00:00
parent 57907b0e6f
commit 96d41ee0b0
4 changed files with 16 additions and 7 deletions

View File

@ -2138,12 +2138,12 @@
{ "id": "multiclock", { "id": "multiclock",
"name": "Multi Clock", "name": "Multi Clock",
"icon": "multiclock.png", "icon": "multiclock.png",
"version":"0.07", "version":"0.08",
"description": "Clock with multiple faces - Big, Analogue, Digital, Text, Time-Date.\n Switch between faces with BTN1 & BTN3", "description": "Clock with multiple faces - Big, Analogue, Digital, Text, Time-Date.\n Switch between faces with BTN1 & BTN3",
"readme": "README.md", "readme": "README.md",
"tags": "clock", "tags": "clock",
"type":"clock", "type":"clock",
"allow_emulator":false, "allow_emulator":true,
"storage": [ "storage": [
{"name":"multiclock.app.js","url":"clock.js"}, {"name":"multiclock.app.js","url":"clock.js"},
{"name":"big.face.js","url":"big.js"}, {"name":"big.face.js","url":"big.js"},

View File

@ -5,6 +5,8 @@
0.05: Add README 0.05: Add README
0.06: Add txt clock 0.06: Add txt clock
0.07: Add Time Date clock and fix font sizes 0.07: Add Time Date clock and fix font sizes
0.08: Add pinned clock face

View File

@ -1,2 +0,0 @@
(function(){return function(){function e(a,d,b,c){a*=k;g.fillPoly([120+Math.sin(a)*d,134-Math.cos(a)*d,120+Math.sin(a+h)*c,134-Math.cos(a+h)*c,120+Math.sin(a)*b,134-Math.cos(a)*b,120+Math.sin(a-h)*c,134-Math.cos(a-h)*c])}function l(){g.setColor(0,0,0);e(360*f.getSeconds()/60,-5,90,3);0===f.getSeconds()&&(e(360*(d.getHours()+d.getMinutes()/60)/12,-16,60,7),e(360*d.getMinutes()/60,-16,86,7),d=new Date);g.setColor(1,1,1);e(360*(d.getHours()+d.getMinutes()/60)/12,-16,60,7);e(360*d.getMinutes()/60,-16,
86,7);g.setColor(0,1,1);f=new Date;e(360*f.getSeconds()/60,-5,90,3);g.setColor(0,0,0);g.fillCircle(120,134,2)}var h=Math.PI/2,k=Math.PI/180,d,f;return{init:function(){f=d=new Date;g.setColor(1,1,1);for(var a=0;60>a;a++){var e=360*a/60,b=e*k,c=120+100*Math.sin(b);b=134-100*Math.cos(b);0==e%90?(g.setColor(0,1,1),g.fillRect(c-6,b-6,c+6,b+6)):0==e%30?(g.setColor(0,1,1),g.fillRect(c-4,b-4,c+4,b+4)):(g.setColor(1,1,1),g.fillRect(c-1,b-1,c+1,b+1))}l()},tick:l}}})();

View File

@ -1,6 +1,8 @@
var FACES = []; var FACES = [];
var iface = 0; var STOR = require("Storage");
require("Storage").list(/\.face\.js$/).forEach(face=>FACES.push(eval(require("Storage").read(face)))); STOR.list(/\.face\.js$/).forEach(face=>FACES.push(eval(require("Storage").read(face))));
var lastface = STOR.readJSON("multiclock.json")||{pinned:0};
var iface = lastface.pinned;
var face = FACES[iface](); var face = FACES[iface]();
var intervalRefSec; var intervalRefSec;
@ -25,7 +27,14 @@ function setButtons(){
face = FACES[iface](); face = FACES[iface]();
startdraw(); startdraw();
} }
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"}); function finish(){
if (lastface.pinned!=iface){
lastface.pinned=iface;
STOR.write("multiclock.json",lastface);
}
Bangle.showLauncher();
}
setWatch(finish, BTN2, {repeat:false,edge:"falling"});
setWatch(newFace.bind(null,1), BTN1, {repeat:true,edge:"rising"}); setWatch(newFace.bind(null,1), BTN1, {repeat:true,edge:"rising"});
setWatch(newFace.bind(null,-1), BTN3, {repeat:true,edge:"rising"}); setWatch(newFace.bind(null,-1), BTN3, {repeat:true,edge:"rising"});
} }